ThomasG
Pine Script Rookie
Pine Script Rookie
Posts: 1
Joined: March 20th, 2022

Backtest only the last x trades

Hi

I would like my script only to backtest the last 20 closed trades from the last closed bar and back. Is that even possible?

Thanks for any help

processingclouds
Pine Script Master
Pine Script Master
Posts: 115
Joined: January 30th, 2022

Re: Backtest only the last x trades

Yes this is possible, you can define the time period and only enter the strategy if it is within your set time bounds.

Return to “Pine Script Q&A”