I am facing problem when not all candles iterate using next().
Imported OHLCV data has 30 ticks, but once I call EMA in init(),
next() called only 1 time.
Which is correct for EMA with default settings, but I need next() called 30 times (per ticks quantity).
I need it to create custom indicator however, so for missing EMA results I can get something like 'NaN'.
import backtrader as bt class Test(bt.Indicator): lines = ('dummy',) def __init__(self): self.ema = bt.indicators.EMA() def next(self): print(bt.num2date(self.data.datetime.dt())) ohlcv_data = bt.feeds.GenericCSVData(dataname='test.csv', headers=False, volume=-1, openinterest=-1) cerebro = bt.Cerebro() cerebro.adddata(ohlcv_data) cerebro.addindicator(Test) cerebro.run()