The trailing stop that we build in most of our custom expert advisors varies somewhat from the generic trailing stops out there. The code uses two inputs. An input is basically a variable that pops up on the screen when you load the expert advisor. You can change the input value without the need for additional programming.
The unique aspect of our trailing stop is that it does not trail until the trade reaches a certain amount of profit. Delaying the adjustment allows the user to treat the stop order as a take profit tool instead of simply exiting at a loss. Most traders feel that once a runner appears, only then does it make sense to adjust the initial rules for exiting at a loss. Acting defensively about the trade only when a decent amount of profit is on the table avoids early stop outs, or at least so the theory goes.
TrailStart is the input which controls when the stop moves from losing to breakeven. It is only at this point of profit that the EA adjusts the exit conditions to avoid a loss.
Say, for example, that the TrailStart is set to activate at 20 pips. That means when your buy trade goes up 20 pips from the entry price, the EA automatically adjusts the stop loss to equal the entry price. The EA cannot lose from that point forward, not counting the effects of slippage.
TrailAmount kicks in only after the stop already adjusted to breakeven. This input controls the distance to increments at which the stop loss should update favorably. If TrailAmount equals 5, it means that the stop loss should adjust in your favor 5 pips for every 5 pips of extra profit beyond the TrailStart at 20 pips.
If the stop loss already moved to breakeven at 20 pips, it means that the stop loss is currently at 0 pips. The trade neither wins nor loses if the market hits the stop. If the price advances another 5 pips (TrailAmount ), the expert advisor determines that it must trail the stop again by 5 pips. The price reaching +25 causes the stop to advance from 0 to +5. When the price moves another 5 pips to +30, the stop advances to +10.
Notice how the stop distance remains a consistent 20 pips in the example. It’s the exact same amount as the TrailStart input.
Leave a Reply