Using multiple apply stops

i was reading the user guide and was interesred in using multiple stops
i was using this code and im not sure if i wrote it correctly.
the idea is to have a stop loss of 5% and if it doesnt get stopped then have a trailng stop of ten percent.
is this the correct way to write it?

SetPositionSize(10, spsPercentOfEquity);
SetOption("MaxOpenPositions", 10);

BuySignal = C > MA(C, 100);

Buy = BuySignal;
Sell = 0;

ApplyStop( stopTypeLoss, stopModePercent, 5, True, False, 0, 0 /precedence/ );
ApplyStop( stopTypeTrailing, stopModePercent, 10, True, False, 0, 1 /precedence/ );
ApplyStop( stopTypeProfit, stopModeDisable, 0, True, False, 0, 2 /precedence/ );
ApplyStop( stopTypeNBar, stopModeDisable, 0, False, False, 0, 3 /precedence/ );

@colombianflag, the code is wrong (and will not execute).

There is no "precedence" parameter in the ApplyStop() function. Please, review its syntax.

From the comments section of the ApplyStop guide page:

If two or more different stops are triggered on the VERY SAME bar then they are evaluated in this fixed order:
Fixed Ruin stop (loosing 99.96% of the starting capital)
Max. loss stop
Profit target stop
Trailing stop
N-bar stop

Moreover, usually, there is no reason to call it with the stopModeDisable flag, if you did not enable a specific type of stop elsewhere in your code or in your configuration.

To change the above order see the SetStopPrecedence() function documentation.

P.S. When are posting some code you should always use the </> button in the forum text editor - see the:

Enter the AFL code properly

section "How to use this site" thread.

2 Likes