Big bug with trailing stop - TS moving backwards
-
Hi,
There seems to be a big issue with trailing stop glitches. Not just when it's used with ATR but also when it's used with fixed pips. And it took me 40 hours of painstaking testing to find when the issue occurs. On backtest sometimes it will go backwards, (TS should never go backwards), jitter up and down a bit, I've even seen it flash right back to initial stoploss quickly, then back to profit. (I tried to attach short video but it's not accepted here).

Here is a snapshot of my trailing stop setting. There are no other conditions that are connected with this trailing stop in my code, and no I don't have other trailing stops connected to it, so nothing else should affect it. The ATR multiplier variable 'ts_atr_mult' is set to 1.0 in this instance and I've had nothing but troubles with the stop jittering up and down once the price gets close to TP. But strange enough, when I change the ATR multiplier to 2, the trailing stop appears to work without glitches.
Now here's what I found really helped the issue:
When I open new trades, the initial stoploss is set to ATR 20 X 3, and this is when the issue is worst. I discovered by accident if I changed the initial stoploss to ATR 20 X 2, it seems the problem goes away. Or at least in most instances that I'm aware of. It seems that there's some kind of conflict between the initial set stoploss and the trailing stop. It's particularly troublesome on backtesting as it slows down a lot while processing a lot more unnecessary and invalid stop moves. Please can this issue be fixed? -
You are connecting a loop block (trailing stop) below another loop block (for each trade). That's why it's not working. They need to be in separate block trees.
-
Put under only bool, if it is still moving backwards, add a condition that checks SL position, compared to new ATR stop position.
-
@l-andorrà Thankyou!
-
@jstap Perfect, thanks for the advice!