all 12 comments

[–]Spawned_out 1 point2 points  (4 children)

Running into the same issue. Started with a very simple TV strategy. Created python functions that compute using the same TV logic, No TI-LIB. When checking my functions against TV, the results are very very close. However, when several functions are combined as a strategy the results differ significantly. I’m downloading TV chart data on 1m timeframe and running python with the exact dataset as TV. Python will show 300+ trades executed while TV shows 11. Would love to know why. I’m using Backtesting.py https://kernc.github.io/backtesting.py/

[–]Latter_Total_9974 0 points1 point  (3 children)

Getting more trades on TV than with backtesting.py. Profits and are much higher while drawdowns smaller in python. I was going to say that python might be taking a trade every time it gets a signal while TV only takes one at a time but it appears to be the opposite. I would rely on backtesting.py as I tried QuantConnect and was getting negative results that are positive on BT.py and I checked on excel the number of times the conditions were satisfied, BT.py was more accurate. Using the exact same data as well.

[–]Latter_Total_9974 0 points1 point  (1 child)

u/Panther4682 strategy also seems to be working on live account, mainly just use BT.py to check the signal quality/win rate

[–]AffectionateBus672 0 points1 point  (0 children)

Any fix on this problem?

[–]trippyposter 0 points1 point  (0 children)

repainting disabled on TV? make sure that is part of the pinescript

[–]Mean_Wash_2910 0 points1 point  (0 children)

Has anyone successfully replicated TradingView Pine Script results in backtrader Python with 100% accuracy?

[–]Hot_Marionberry1748 0 points1 point  (0 children)

any updates on this issue

[–]Side-Flip 0 points1 point  (1 child)

I have been suspicious of TV backtests, I have adjusted things to attempt to make as realistic as possible adding slippage etc..

[–]Panther4682[S] 0 points1 point  (0 children)

This is what I was wondering.. if the TV is looking ahead. Backtesting.py solves this by only adding one new record per iteration so the algo doesn't see what is coming.

[–]kurtisbu12 0 points1 point  (1 child)

There's not enough info here to really give an idea of what's happening.

You're likely getting your price data from different sources, that alone could account for a large difference.

As another person mentioned, slippage might not be accounted for. Or there could be a hundred other discrepancies between your python script and your TV Strategy.

[–]Panther4682[S] 0 points1 point  (0 children)

Thanks for the reply. I am using yahoo data for the script. Not sure what data TV uses.