简体   繁体   中英

Backtrader - trades not lining up on .plot

I am trying to learn backtrader, but when using my own data (1 min. charts), I am having this issue, where the trades are not lining up with the graph. 格罗普

Don't mind the many trades, there is not set a proper strategy at the moment as I am just testing out and trying to learn backtrader. I have looked around and read the reply's for other people who were having same issue. What fixed it for them in most cases was to add stdstats=False and a BuySell observer.


cerebro = bt.Cerebro(stdstats=False)
cerebro.addobserver(bt.observers.BuySell)

I have also declared that my timeframe is minutes:


data = bt.feeds.GenericCSVData(
        dataname='BTCUSD2.csv',
        timeframe=bt.TimeFrame.Minutes,
        fromdate=datetime.datetime(2021, 1, 1),
        todate=datetime.datetime(2021, 1, 17),
        reverse=False)

I simply can't figure out what else might be wrong?

notice other reports of this kind o problem here:

basically you need to change this line, and add barplot and bardist according documentation

cerebro.addobserver(bt.observers.BuySell, barplot=True, bardist=0.0025)

the value above 0.0025 is just an example.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM