For code/output blocks: Use ``` (aka backtick or grave accent) in a single line before and after the block. See:

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 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

    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(, period=self.p.smaperiod)
        self.atr = bt.indicators.ATR(, period=20)
        self.highest = bt.indicators.MaxN(, period=12)
        self.lowest = bt.indicators.MinN(, period=12)
        self.margin = 0.0025
        print('Strategy Created')

  • Removed for edit

  • administrators

    That code for sure is not enough to tell why next is called. But if you are using the oandatest sample, this sample calls next from prenext, because the point is seeing all received data and not waiting for the indicators.

  • @backtrader Thank you, fixed.

Log in to reply