Overall Statistics |
Total Trades 0 Average Win 0% Average Loss 0% Compounding Annual Return 0% Drawdown 0% Expectancy 0 Net Profit 0% Sharpe Ratio 0 Loss Rate 0% Win Rate 0% Profit-Loss Ratio 0 Alpha 0 Beta 0 Annual Standard Deviation 0 Annual Variance 0 Information Ratio 0 Tracking Error 0 Treynor Ratio 0 Total Fees $0.00 |
# MultiIndicator v2 (Py) from clr import AddReference AddReference("System") AddReference("QuantConnect.Algorithm") AddReference("QuantConnect.Indicators") AddReference("QuantConnect.Common") from System import * from QuantConnect import * from QuantConnect.Data import * from QuantConnect.Algorithm import * from QuantConnect.Indicators import * from datetime import datetime import decimal as d import numpy as np class MultiIndicator(QCAlgorithm): def Initialize(self): # define email address for buy/sell notifications # please change prior to Live deploy self.email_address = 'test@test.com' self.SetStartDate(2017,11,1) #Set Start Date self.SetEndDate(2017,11,2) #Set End Date self.SetCash(3000) #Set Strategy Cash # define crypto we want to trade on # ETHUSD or LTCUSD or BTCUSD self.target_crypto = "ETHUSD" # Set brokerage to GDAX for cryptos self.SetBrokerageModel(BrokerageName.GDAX, AccountType.Cash) # Set crypto and time resolution self.AddCrypto(self.target_crypto, Resolution.Minute) self.SetBenchmark(self.target_crypto) # Request warmup data self.SetWarmup(120) # create consolidator for 1 minute # even though base resolution is already Minute, # manually consolidating at the same resolution # ensures pattern can be the same for larger resolution bars. consMinute = TradeBarConsolidator(1) consMinute.DataConsolidated += self.OnMinuteData self.SubscriptionManager.AddConsolidator(self.target_crypto, consMinute) # create consolidator for 5 minute cons15Minute = TradeBarConsolidator(5) cons15Minute.DataConsolidated += self.On15MinuteData self.SubscriptionManager.AddConsolidator(self.target_crypto, cons15Minute) # Define EMAs at minute consolidated resolution # Note we are at minute resolution self.ema_minute_f = ExponentialMovingAverage("EMA_Min_f", 2) self.ema_minute_m = ExponentialMovingAverage("EMA_Min_m", 15) self.ema_minute_s = ExponentialMovingAverage("EMA_Min_s", 120) # Define MOMs at 15 minute consolidated resolution # Note we are at 15 minute resoltuion self.mom_15minute_f = self.MOM(self.target_crypto, 3) sPlot = Chart('Strategy Equity') sPlot.AddSeries(Series('EMA Crossover', SeriesType.Line, 2)) #Only for axis title override sPlot.AddSeries(Series('EMA 2min', SeriesType.Line, 2)) sPlot.AddSeries(Series('EMA 15min', SeriesType.Line, 2)) sPlot.AddSeries(Series('EMA 120min', SeriesType.Line, 2)) sPlot.AddSeries(Series('Momentum', SeriesType.Line, 3)) self.AddChart(sPlot) # Initialize variables self.holdings = 0 self.tolerance = .001 self.price = self.Securities[self.target_crypto].Price self.price_last_buy = None self.price_max = None self.price_delta_buy = None self.price_delta_max = None self.first = True def OnMinuteData(self, sender, bar): self.ema_minute_f.Update(bar.EndTime, bar.Close) self.ema_minute_m.Update(bar.EndTime, bar.Close) self.ema_minute_s.Update(bar.EndTime, bar.Close) #self.Debug(str(self.Time) + " > New Minute Bar!") self.Plot('Strategy Equity', 'EMA 2min', float(str(self.ema_minute_f))) self.Plot('Strategy Equity', 'EMA 15min', float(str(self.ema_minute_m))) self.Plot('Strategy Equity', 'EMA 120min', float(str(self.ema_minute_s))) def On15MinuteData(self, sender, bar): self.mom_15minute_f.Update(bar.EndTime, bar.Close) #self.Debug(str(self.Time) + " > New Minute Bar!") self.Plot('Strategy Equity', 'Momentum', float(str(self.mom_15minute_f))) def OnData(self, data): if self.first and not self.IsWarmingUp: self.first = False pass