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 Probabilistic 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 |
from QuantConnect.Indicators import AverageTrueRange, Maximum class MACDTrendAlgorithm(QCAlgorithm): def Initialize(self): '''Initialise the data and resolution required, as well as the cash and start-end dates for your algorithm. All algorithms must initialized.''' self.SetStartDate(2020, 6, 23) #Set Start Date self.SetEndDate(2020, 6, 23) #Set End Date self.SetCash(100000) #Set Strategy Cash self.MySymbol = "EURUSD" self.AddForex(self.MySymbol, Resolution.Minute) self.Trade = False self.TheHigh = [] self.IndicatorLength = 22 self.AtrIndicatorMinute = self.ATR(self.MySymbol, self.IndicatorLength) self.MaxIndicatorMinute = self.MAX(self.MySymbol, self.IndicatorLength) self.AtrIndicator15Minute = AverageTrueRange(self.IndicatorLength) self.MaxIndicator15Minute = Maximum(self.IndicatorLength) self.TimeFrame = 15 #15 minute bars self.SetWarmup(100) #I got this from: https://www.quantconnect.com/docs/algorithm-reference/consolidating-data self.consolidator = QuoteBarConsolidator(self.TimeFrame) self.consolidator.DataConsolidated += self.CustomHandler self.SubscriptionManager.AddConsolidator(self.MySymbol, self.consolidator) #self.Schedule.On(self.DateRules.EveryDay(), self.TimeRules.At(8,45), self.GettingHigh) self.Schedule.On(self.DateRules.EveryDay(), self.TimeRules.At(9,00), self.TradingTime) self.Schedule.On(self.DateRules.EveryDay(), self.TimeRules.At(9,46), self.TradingTimeEnd) def TradingTime(self): self.Trade = True self.GetHigh = True def TradingTimeEnd(self): self.Trade = False self.GetHigh = False def OnData(self, data): if self.Trade: self.TheHigh.insert(0,self.Securities[self.MySymbol].High) self.Log("1 Minute ATR: " + str(self.AtrIndicatorMinute.Current.Value)) self.Log("1 Minute High " + str(self.MaxIndicatorMinute.Current.Value)) def CustomHandler(self, sender, consolidated): self.AtrIndicator15Minute.Update(consolidated) self.MaxIndicator15Minute.Update(consolidated.Time, consolidated.High) if self.Trade: self.Log(" 15 Minute ATR: " + str(self.AtrIndicator15Minute.Current.Value)) self.Log(" 15 Minute High " + str(self.MaxIndicator15Minute.Current.Value))