Relevant sections below.
Code: Select all
inputs:
TrailingATR_LB(40),
TrailingATR_Multiple(2);
variables:
trailingSize(0), atrSize(0);
atrSize = AvgTrueRange(TrailingATR_LB);
trailingSize = atrSize * TrailingATR_Multiple;
setstopcontract;
setdollartrailing(trailingSize);
Meaning, the trailing stop is only activated when the price moves sharply back on a specific day. If the move to the other direction of the position is done gradually, day by day, the trailing will never be activated.
If the trailing is constant rather then being calculated, it works correctly.
I noticed it in backtest mode, in a short position in a stock.
Will appreciate feedback and suggestions.