Relevant sections below.
I found out that instead of being activated when the current profit is less than the maximum profit by trailingSize, it is done when the profit is less than the maximum profit achieved at that specific day.
Code: Select all
atrSize = AvgTrueRange(TrailingATR_LB);
trailingSize = atrSize * TrailingATR_Multiple;
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.