Move Stop to BE with an array

Hi guys,

I have a question regarding Break-Even StopLoss. Consider the below Code:

SL = BuyPrice - Ref( L, -1 );
ApplyStop( stopTypeLoss, stopModePoint, 0, True, False, 0, 0, -1, SL );

Here I want to move SL to the entry when price moved equally as SL amount. However, ApplyStop expect a number here not an array!
How can I fix this?


@Tomasz Would you please advice, if there is any solution to this?

You simply need trail stop instead max loss. Trail stop moves up as prices move to new highs. Max loss doesn't.

Thank Tomasz.
I already tried some combinations with no success. Would you please give an example? how can I trail (Move) my stop only once with stopTypeTrailing.
In any case, we need to set ActivationFloor which cannot be an array.

To have full control over your stop/s, use a For Loop.

See here as a starting point.

Break even stop example is available here (6.25 or higher):

If I understand correctly, it is not possible to move SL to BE, while price moved a certain amount (variable for each trade) without loop.
Am I right?
Let's consider an example in future mode. if I bought CADCHF at
EP: 0.69434
SL: 0.69280 (SL distance 15 pips)
TP: 0.69727

  1. Is it possible to Move SL to EP if price moved 15 pips toward TP?

Regarding this example:

// Example 1:
// Break-Even stop with 10% activation floor amount
// activation amount is last 9th argument
ApplyStop( stopTypeLoss, stopModePercent, 0, True, False, 0, 0, -1, 10 );
  1. What does "activation amount is last 9th argument" means?

  2. I have difficulties to understand what does that 10% means? 10% of what? Considering the above example, when Trailing Stoploss will be activated?

  3. Is it possible to trail the SL only Once?


I bring this topic up again, hopefully, @Tomasz or someone assists.
Especially, I confused with "stopModePercent" in Forex. How this percentage will be calculated. If this is 10% of Profit/Loss, then how that profit/Loss should be calculated.
This is important so one can implement this on a strategy that will be developed on MT4 for example.

See ApplyStop.
See How to Debug.


I prepared this code to Break Even my trade after price moved in favour for more than StopLoss amount. Can anyone help me how this loop should be formulated to work properly?

BuyPrice 	= H; 
SL = H - L;  

for( i = 1; i < BarCount; i++ )

   if( Buy[ i ]  AND ( Close[ i ] - BuyPrice[ i ] ) > SL[ i ] ) 
      SL[ i ] = 0;


ApplyStop(stopTypeLoss,   stopModePoint,   SL, 1, 0);

Refer to this code by @fxshrat,