I'm trying to get the day and hour of when high or low has occurred using Rolling window.

  1. class RetrospectiveAsparagusMule(QCAlgorithm):
  2. def Initialize(self):
  3. self.SetStartDate(2019, 12, 31)
  4. self.SetEndDate(2020,6,1)
  5. self.SetCash(1000)
  6. for symbol in self.curr:
  7. self.eurusd = self.AddForex(symbol, Resolution.Hour).Symbol
  8. self.SetBenchmark(symbol)
  9. self.Consolidate(self.eurusd, timedelta(hours=4), self.HourQuoteBarHandler)
  10. self.window = RollingWindow[QuoteBar](60)
  11. #self.SetWarmUp(60)
  12. def OnData(self, data):
  13. if not (self.window.IsReady):
  14. return
  15. for symbol in self.curr:
  16. price = data[symbol].Close
  17. time = {}
  18. for i in range(60):
  19. self.high_values.append(self.window[i].High)
  20. self.low_values.append(self.window[i].Low)
  21. time[self.window[i].High] = self.Time
  22. time[self.window[i].Low] = self.Time
+ Expand

In this case self.Time will return only the actual time of the backtest and not the value I'm looking for which is the time at which the high and low have occurred on the chart.

Is this something that can only be achieved through history request?

 

 

Author

SIG_94

September 2021