ApplyStop Function and Placing Limits on Trade Losses

// STRUCTURE //

SetBacktestMode(backtestRegular);
SetOption("FuturesMode", 1);
SetOption("CommissionMode", 3);
SetOption("CommissionAmount", 1);
SetOption("InitialEquity", 100000000);
SetOption("ReverseSignalForcesExit", True);
SetOption("AllowSameBarExit", False);
SetOption("GenerateReport", 1);


// ENTRY AND EXIT SIGNALS //

Buy = Close > Ref(HHV(High, 126), -1 );
Short = Close < Ref(LLV(Low, 126), -1 );
Sell = Cover = 0;

InitialStopLength = (5 * ATR(60));
SubsequentStopLength = (8 * ATR(60));
ApplyStop (stopTypeLoss, stopModePoint, InitialStopLength, 2, False, 1);
ApplyStop (stopTypeLoss, stopModePercent, 50, 2, False, 1);
ApplyStop (stopTypeTrailing, stopModePoint, SubsequentStopLength, 2, True, 1);
ApplyStop (stopTypeTrailing, stopModePercent, 50, 2, True, 1);

SetStopPrecedence (stopTypeLoss, stopTypeTrailing, stopTypeNBar, stopTypeProfit);

Under the "Trades" category of the backtest report, the first trade under the "Profit" column indicates that I have lost 139% of the profit from the trade.

However, with this line ApplyStop (stopTypeLoss, stopModePercent, 50, 2, False, 1); , I have been trying to limit my maximum loss to 50%.

Any helpful thoughts or comments on why my maximum loss from a trade is exceeding 50% will be appreciated.

First your code has an error.

ApplyStop (stopTypeLoss, stopModePoint, InitialStopLength, 2, False, 1);
ApplyStop (stopTypeLoss, stopModePercent, 50, 2, False, 1); // WOULD OVERWRITE previous stopTypeLoss

and

ApplyStop (stopTypeTrailing, stopModePoint, SubsequentStopLength, 2, True, 1);
ApplyStop (stopTypeTrailing, stopModePercent, 50, 2, True, 1); // WOULD OVERWRITE previous stopTypeTrailing

If you call ApplyStop with SAME STOP TYPE a subsequent call to ApplyStop with same stop type OVERWRITES what you had set before. You can't have two stops of the same type

As to your actual question:

There are many situations when your losses will be bigger than stop loss.
One of most often is when you have GAP on OPEN. When prices gap on open more
than you stop loss is set to, the trade will be closed at open
price which will result in loss bigger than stop loss.
Even markets that operate 24-hours per day (such as forex) can
experience that because those markets can open on Monday gap
(after weekend).

1 Like

Thanks @Tomasz for the clarification.

This topic was automatically closed 100 days after the last reply. New replies are no longer allowed.