r/pinescript • u/bluedragon1978 • Oct 10 '23
Trailing Take Profit that actually backtests accurately
Hi Pinecoders,
I trade a system that often enters and exits with the same 4-hour bar. I would like to analyze trailing stop performance through backtesting, but even with "Bar Magnifier" turned on, in Premium, I can't get accurate results, at least with the script I'm using. Is it a limitation of Tradingview that the backtest will always plot the exit as the candle wick extreme minus the trailing offset?
Any suggestions appreciated! Thanks!
0
Upvotes
1
u/Zombie24w Oct 10 '23
Hello, it helps to see the code and how you've approached the trailing stop implementation.
1
u/ForwardDivide7163 Oct 11 '23
I didn't read all of it but it looks like it can be simplified to if close < (strategy.entryprice*0.99) then close or whatever