I'm trying to get the day and hour of when high or low has occurred using Rolling window.
class RetrospectiveAsparagusMule(QCAlgorithm):
def Initialize(self):
self.SetStartDate(2019, 12, 31)
self.SetEndDate(2020,6,1)
self.SetCash(1000)
for symbol in self.curr:
self.eurusd = self.AddForex(symbol, Resolution.Hour).Symbol
self.SetBenchmark(symbol)
self.Consolidate(self.eurusd, timedelta(hours=4), self.HourQuoteBarHandler)
self.window = RollingWindow[QuoteBar](60)
#self.SetWarmUp(60)
def OnData(self, data):
if not (self.window.IsReady):
return
for symbol in self.curr:
price = data[symbol].Close
time = {}
for i in range(60):
self.high_values.append(self.window[i].High)
self.low_values.append(self.window[i].Low)
time[self.window[i].High] = self.Time
time[self.window[i].Low] = self.Time
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?
Arthur Asenheimer
Hi,
you can access the time value as follows:
SIG_94
Great, thanks. My bad I didn't realise it was that simple😊
SIG_94
The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by QuantConnect. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. QuantConnect makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances. All investments involve risk, including loss of principal. You should consult with an investment professional before making any investment decisions.
To unlock posting to the community forums please complete at least 30% of Boot Camp.
You can continue your Boot Camp training progress from the terminal. We hope to see you in the community soon!