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

Difference between Backtrader and TradingView?



  • Hello,

    Thank you for the amazing work on this very useful tool.
    I'm discovering algo trading and backtesting methods.

    I have differences between Backtrader and TradingView using the same strategy that I would like to understand.

    But the trades that both platforms are doing are totally different.

    See what I have on Backtrader (only 7 trades on the timeframe):
    02fe5e5c-9907-4b92-8915-149a0853c73f-image.png

    And see what I have on TradingView (many more trades are being done!):
    04c51398-8454-4c61-9b12-bbbf88aec74e-image.png

    I do have the same value on both platforms for these parameters:

    • data = bitcoin/usd
    • 1 bar per day
    • MACD strategy: short=12, long=21, macd=17

    What other parameters could explain this difference? I must miss something.

    Thanks



  • @alexfr said in Difference between Backtrader and TradingView?:

    What other parameters could explain this difference?

    Based on the amount of data provided (couple pictures) the following can be said for sure: you have a mistake(s) somewhere in one of your scripts. Or you have mistakes in both of the scripts, therefore all results shown are wrong.

    I must miss something.

    You miss the main thing - the author of the code debugs the code. Print all the inputs and outputs, go bar by bar, do spot check by hands, compare results, find differences, get back to the script, identify what is the reason for differences, make corrections if necessary.

    Good luck!


  • administrators

    Adding to what @ab_trader said, there is something clear by simply looking at the charts: IT' NOT THE SAME DATA. It looks similar, but it isn't the same.

    If that doesn't suffice to let you understand where there difference lies ... well people can read code and data, but people cannot read charts (people can spot patterns in the chart to understand things like that it is not the same data)



  • Thanks for your replies!
    I was investigating more and found an issue with my MACD strategy implementation on backtrader. By correcting it, I get almost the exact same trades as on TradingView.
    That's a good sign for me that I'm not doing bullshit with backtrader, yay.


Log in to reply
 

});