khramkov / Backtrader-MQL5-API

Python Backtrader - Metaquotes MQL5 - API
GNU General Public License v3.0
247 stars 90 forks source link

only a larger bar completes, the next method of the strategy is triggered #6

Open quantcn opened 3 years ago

quantcn commented 3 years ago

Hi, Author, thank you for your good work. I have a problem, please see below. I have two datas: 1minute and 5minute bar. But in he next, only a 5miniute bar completes, the next method of the strategy is triggered. I expect that when a 1minute bar completes, the next method should be triggered. Any idea?

`cerebro = bt.Cerebro() cerebro.addstrategy(SmaCross)

store = MTraderStore(debug=True)

broker = store.getbroker() # use_positions=True cerebro.setbroker(broker)

start_date = datetime.now() - timedelta(minutes=52460) start_date2 = datetime.now() - timedelta(minutes=52460)

data = store.getdata(dataname='EURUSD', timeframe=bt.TimeFrame.Minutes, compression=1, backfill = True, fromdate=start_date , tz=pytz.timezone('Asia/Shanghai'))
data2 = store.getdata(dataname='EURUSD',timeframe=bt.TimeFrame.Minutes, compression=5, backfill = True, fromdate=start_date2 , tz=pytz.timezone('Asia/Shanghai'))

cerebro.adddata(data, name='EURUSD') cerebro.adddata(data2, name='EURUSD2')

cerebro.run(stdstats=False)`