Hi programmers,
I use the attached EA to trail my SL behind the previous candle's high/low.
I would like to have the EA modified in that way that the stop loss is only moved if the candle closes in the direction of the trade (perhaps to turn it on/off in the input parameters).
For example: In a long trade if the previous bar closed bearish (close < open), the SL should NOT be moved, ONLY if the bar closed bullish (close > open).
The default parameters are:
iTicket: put in the ticket number of the trade you want to monitor (first column in MT4 terminal)
iTmfrm: timeframe of which EA should trail by bars (e.g. 60 for H1)
iBars_n: number of bars for which the SL should be calculated (e.g. 2 means high/low of the last 2 bars, I use 1 for the previous bar)
iIndent: buffer in pips for SL (e.g. 10 means the SL will be placed 1 pip -for 5 digit broker- below/above the high/low of the last candle)
bTrlinloss: TRUE = SL will be moved even in loss (I use this) or FALSE = SL will only be moved if new SL is in profit
It would be great if someone coud do the little modification. Many thanks in advance.
Cheers,
Olarion
I use the attached EA to trail my SL behind the previous candle's high/low.
I would like to have the EA modified in that way that the stop loss is only moved if the candle closes in the direction of the trade (perhaps to turn it on/off in the input parameters).
For example: In a long trade if the previous bar closed bearish (close < open), the SL should NOT be moved, ONLY if the bar closed bullish (close > open).
The default parameters are:
iTicket: put in the ticket number of the trade you want to monitor (first column in MT4 terminal)
iTmfrm: timeframe of which EA should trail by bars (e.g. 60 for H1)
iBars_n: number of bars for which the SL should be calculated (e.g. 2 means high/low of the last 2 bars, I use 1 for the previous bar)
iIndent: buffer in pips for SL (e.g. 10 means the SL will be placed 1 pip -for 5 digit broker- below/above the high/low of the last candle)
bTrlinloss: TRUE = SL will be moved even in loss (I use this) or FALSE = SL will only be moved if new SL is in profit
It would be great if someone coud do the little modification. Many thanks in advance.
Cheers,
Olarion
Attached File(s)
TrailingByShadows.mq4
6 KB
|
534 downloads