Pine Script

Backtesting Pine Script Strategies on entire history with Deep Backtesting

Backtesting Pine Script Strategies on entire history with Deep Backtesting

If you backtest a lot of strategies in TradingView you most likely know that that TradingView is a bit limited in terms of backtesting. If you run backtest in a standard way you get your backtest computed on the last ~ 20k bars only for the most expensive account. And that’s not enought for majority of the strategies to understand if your result is robust or not. There is a hack to increase amount of bars in backtesting, but that’s not very nice approach and it doesn’t help much.

Fortunately that changed now. When you add your strategy to your chart you now can spot a “Deep backtesting” checkbox on the right of your Strategy Tester:

To use it you have to switch it on, fill the from / to dates and click “Generate report”:

Pine script compute your report for few moemnts and then it wll present to you in the same format as regular reports are presented. But it will use all the data for the instrument in the date range you specified.

So let’s look at one of the strategies. I used BTCUSD on bitstamp as an instrument and here standard results:

Results looks pretty solid, we have 2+ profit factor, but only 105 trades. When checking the trades I see that trades tarted only 22nd of March, which is less than 5 months of history. I don’t think it’s enough so let’s try to run this with Deep backtesting enabled.

I did set date range from 1st of Jan 2012 to today:

And here are results:

As you can see performance deteriorated a bit and not we have profit factor of only 1.35. Maybe it doesn’t worth to trade this strategy now.

But take a look at number of trades, we have almost 3k trades and this is 30 times more in the standard backtest! If we’ll check the trades we’ll see that fisrt trade for it really happened in 2012:

So that’s a really cool tool that you can easily use to backtest your strategies on entire history of data. Deep backtesting is still in beta, so I expect some bugs for now. But overall it’s amazing what TradingView managed to implement. You can easily now backtest 10 years of 10m bars in matter of seconds. If you’re not using this feature for now – give it a try, it’s quite cool.


Follow me on TradingView and YouTube.

This image has an empty alt attribute; its file name is wide.png

Leave a Comment

Your email address will not be published. Required fields are marked *

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

Pine Script Programming Courses
Pine Script Programming Courses
Learn to build your own TradingView Indicators and Strategies
Sidebar Signup Form
If you want to be the first in this business, subscribe to the latest news