Next() call not being delayed
-
I have an indicator with a period of 12 being initialized in my strategy.
I am compressing 60 minutes into hour long bars.
Based off of what I read on the wiki - the first next() call should not occur until 12 hours have passed in the data, correct? Yet my next() call is being triggered with only one item in self.data. Is there something I misunderstood with how compression works?
edit: Just tried to remove compression and I still have the same issue. Here is my init function, using most of the boilerplate in oandatest.py
I tried removing compression and this issue still occurs. Below is my strategy init function:
def __init__(self): # To control operation entries self.orderid = list() self.order = None self.counttostop = 0 self.datastatus = 0 # Create SMA on 2nd data self.sma = bt.indicators.MovAv.SMA(self.data, period=self.p.smaperiod) self.atr = bt.indicators.ATR(self.data, period=20) self.highest = bt.indicators.MaxN(self.data, period=12) self.lowest = bt.indicators.MinN(self.data, period=12) self.margin = 0.0025 print('--------------------------------------------------') print('Strategy Created') print('--------------------------------------------------')
-
Removed for edit
-
That code for sure is not enough to tell why
next
is called. But if you are using theoandatest
sample, this sample callsnext
fromprenext
, because the point is seeing all received data and not waiting for the indicators. -
@backtrader Thank you, fixed.