Skip to main content
Version: 2.0

SLT - Stop Loss Trailing

Concept diagram

The concept diagram provided below depicts the function block associated with this page.

Concept diagram, Stop Loss Trailing.png

Enabling of stop loss trailing types and changing between them

The stop loss trailing logic is vital to the underlying trading framework. It changes the stop loss as the price shifts favorably and can even manage transitions between different stop loss trailing methods. The input parameters are divided into two parts: one specifies the types of trailing methods to be used and the timing for switching between them, while the other sets the parameters for the underlying algorithms of each trailing method. Once the trailing method is configured, it applies to every trade opened with the trading module.

The table below provides a comprehensive list of the input parameters required to activate the stop loss trailing feature.

Input variable within MetaTrader
(Identifier in SET file)
Default valueComment
> (SLT) A Type
(IN_enmSltAType)
ATRSNumeric values usable in SET files:
0 - OFF
1 - FIX
2 - BREAKEVEN
3 - MARKET
4 - ATRS
5 - PARABOLIC SAR
6 - STEPWISE
7 - TIME CLOSING
8 - LINEAR
9 - LAST HIGH/LOW
> (SLT) B Type
(IN_enmSltBType)
OFFNumeric values usable in SET files:
0 - OFF
1 - FIX
2 - BREAKEVEN
3 - MARKET
4 - ATRS
5 - PARABOLIC SAR
6 - STEPWISE
7 - TIME CLOSING
8 - LINEAR
9 - LAST HIGH/LOW
> (SLT) C Type
(IN_enmSltCType)
OFFNumeric values usable in SET files:
0 - OFF
1 - FIX
2 - BREAKEVEN
3 - MARKET
4 - ATRS
5 - PARABOLIC SAR
6 - STEPWISE
7 - TIME CLOSING
8 - LINEAR
9 - LAST HIGH/LOW
> (SLT) AB change position (-1 -> OFF)
(IN_nSltABChangePosition)
-1The input value cannot be smaller than -1.
> (SLT) BC change position (-1 -> OFF)
(IN_nSltBCChangePosition)
-1The input value cannot be smaller than -1.

Three of the listed input parameters define the applied stop loss trailing methods (> (SLT) A Type, > (SLT) B Type, and > (SLT) C Type), and two define when the switch between the trailing types will take place. With these input parameters, it is easy to instruct the trading module to start with a breakeven trailing and activate the ATR-based stop loss trailing once the profit increases further.

Please refer to the illustration below to understand how the stop loss trailing works. As you can see, this illustration displays a performed trade with sophisticated stop loss management. In the first phase of the trade, breakeven trailing was active (> (SLT) A Type). As soon as the trigger point (> (SLT) AB change position) for switching was reached, the > (SLT) B Type (ATRS) became active. With further progress and by reaching the next trigger point (> (SLT) BC change position), the stop loss changed to the market trailing method (> (SLT) C Type).

The switching position is as follows: The initial stop loss difference when a trade is opened represents the unitless value of 100; let's assume it has been 80 pips. When > (SLT) AB change position is configured to 150, the actual change in trailing types occurs when the price reaches 120 pips above the initial stop loss. The initial stop loss is used as a static reference for this calculation. The same applies to > (SLT) BC change position.

You can choose from the following trailing types. Each trailing method can be used for different trading strategies. Some are indicator-based, and some are market-based:

  • Off
  • Fix
  • Breakeven
  • Market
  • ATRS
  • Parabolic SAR
  • Stepwise
  • Time closing
  • Linear
  • Last High/Low

These methods can be combined to match your stop loss preference. The default stop loss is an ATRS-based trailing method without switching to any other trailing method.

Configuration, Stop Loss Trailing, Function principle.png

The stop loss trailing function is typically illustrated with a series of example charts. The following charts provide a visual representation of this function.

Configuration, Stop Loss Trailing, Example charts.png
tip

To reproduce the chart from above, you can download and use the SET file package um_eab_cslt_3_v_2_0.zip.

  • Example chart a) Demonstrates a simple ATRS trailing.
  • Example chart b) First breakeven trailing, second ATRS trailing.
  • Example chart c) First breakeven trailing, second ATRS trailing, third deactivated trailing.
  • Example chart d) First breakeven trailing, second ATRS trailing, third marketing trailing.

Parameters for breakeven trailing

The breakeven trailing method implies that the stop loss value is only modified once at a specific price. This ensures that already-made profits are secured. The sudden jump in stop loss will occur when the trade is already in a respectable profitable zone, and it's not expected that the trade will change its direction.

Input variable within MetaTrader
(Identifier in SET file)
Default valueComment
> (SLT) Breakeven position
(IN_nSltBreakevenPosition)
130The input value cannot be smaller or equal to 0.

You can use the Breakeven position input parameter to define the moment when the jump will occur. The initial distance between the opening price and initial stop loss represents the reference value 100. Let's assume this was 80 pips. If the > (SLT) Breakeven position is set to 150, the jump to breakeven will occur when the price rises 40 pips above the opening price. As seen in the illustration below, the larger the breakeven position, the later the jump.

Configuration, Stop Loss Trailing, Breakeven trailing, Function principle and example charts.png
tip

To reproduce the chart from above, you can download and use the SET file package um_eab_cslt_4_v_2_0.zip.

danger

This trailing method should only be used with a take profit or by manual supervision and closing the trade. Since the stop loss value never changes again, the maximum outcome will be zero profit. Fees such as commission or swap are not included in the calculation of the breakeven price.

Parameters for market trailing

Market trailing doesn't rely on complex algorithms. Instead, it uses the open and close prices of the previous candle sticks, combined with the spread, to calculate its movements. The only adjustable variable is a buffer added to the stop loss distance. This buffer can be calculated by two parameters: a fixed value measured in pips (> (SLT) Market buffer fix) or/and a dynamic value based on the current spread (> (SLT) Market buffer spread).

Input variable within MetaTrader
(Identifier in SET file)
Default valueComment
> (SLT) Market buffer fix
(IN_dSltMarketBufferFix)
10.0This parameter introduces a buffer to the stop loss level, calculated based on a fixed number of pips.
The input value cannot be smaller or equal to 0.
> (SLT) Market buffer spread
(IN_dSltMarketBufferSpread)
4.0This parameter introduces a buffer to the stop loss level, calculated based on a fixed number of pips. However, in this case, the parameter multiplies the current spread value. The product of this multiplication determines the buffer level.
The input value cannot be smaller or equal to 0.

Based on the spread, the dynamic option is handy to avoid being stopped during night hours. For instance, the ask price is crucial for long trades to define when a trade will close. However, the stop loss level might come too close if the spread is too large. Therefore, during phases of large spread, the market trailing variant can automatically adapt the buffer to better react in volatile phases or during night hours.

The effect of the input parameter can be observed in the chart below.

Configuration, Stop Loss Trailing, Market trailing, Function principle and example charts.png
tip

To reproduce the chart from above, you can download and use the SET file package um_eab_cslt_5_v_2_0.zip.

As can be seen, both parameters move the stop loss line further away from the actual price. Both buffer types can be combined freely. If used together, their values will be added to each other.

Parameters for average true range trailing

The average true range (ATR) trailing method employs an ATR indicator to calculate the stop loss distance. This widely used indicator is a standard tool for assessing a price chart's volatility.

Input variable within MetaTrader
(Identifier in SET file)
Default valueComment
> (SLT) ATRS multiplier
(IN_dSltAtrsMultiplier)
3.5The input value cannot be smaller or equal to 0.
> (SLT) ATRS period
(IN_nSltAtrsPeriod)
14The input value cannot be smaller or equal to 0.

The parameters for configuring the ATR trailing method include the > (SLT) ATRS period, the period used to calculate the ATR indicator, and the > (SLT) ATRS multiplier. The raw ATR value is typically too small to be used as a trailing stop loss distance, so it's common to multiply the raw indicator value with a multiplier. A frequently used value for the multiplier is 3.5.

Configuration, Stop Loss Trailing, Average true range trailing, Function principle and example charts.png
tip

To reproduce the chart from above, you can download and use the SET file package um_eab_cslt_6_v_2_0.zip.

By adjusting these values, the ATR trailing method can respond more to the current price.

Parameters for parabolic SAR trailing

Parabolic SAR (PSAR) trailing stop losses utilize a PSAR indicator, another standard tool in modern trading. This indicator usually comes with two input parameters.
Input variable within MetaTrader
(Identifier in SET file)
Default valueComment
> (SLT) PSAR step
(IN_dSltPsarStep)
0.02The input value cannot be smaller or equal to 0.
> (SLT) PSAR maximum
(IN_dSltPsarMaximum)
0.2The input value cannot be smaller or equal to 0.

The PSAR value is directly taken as the stop loss, depending on whether the current PSAR value qualifies. Since the PSAR is drawn above or below the price chart, there are phases when the PSAR does not output valid values for stop losses. This typically happens when a trade is opened. When the PSAR changes its characteristic, the stop loss may move quickly close to the price. The input parameters > (SLT) PSAR step and > (SLT) PSAR maximum are used to adapt this movement.

Configuration, Stop Loss Trailing, Parabolic SAR trailing, Function principle and example charts.png
tip

To reproduce the chart from above, you can download and use the SET file package um_eab_cslt_7_v_2_0.zip.

The lower these values are, the more gently the stop loss moves towards the price value.

Parameters for stepwise trailing

The stepwise trailing method incrementally moves the stop loss closer to the current price. Each step is of equal size, and the next step is executed when the price increases by a specified value. As is customary in this application, the input parameters for this trailing method are defined with relative parameters. In this case, the initial stop loss difference, the price difference between the opening price and the initially configured stop loss, represents the unitless reference value of 100.

Input variable within MetaTrader
(Identifier in SET file)
Default valueComment
> (SLT) Steps size
(IN_nSltStepsSize)
80The input value cannot be smaller or equal to 0 and not greater than or equal 100.
> (SLT) Steps position
(IN_nSltStepsPosition)
130The input value cannot be smaller or equal to 100.

The input parameter > (SLT) Steps size determines the size of each step, while > (SLT) Steps position indicates when the next step will be executed. As previously mentioned, both values are relative. For instance, if the initial stop loss difference is 100 pips and > (SLT) Steps size is set to 130, the next step will occur when the price reaches initial stop loss + 130 pips. Subsequently, the next step will be executed at initial stop loss + 260 pips. This pattern will continue until the trade is eventually stopped out.

If > (SLT) Steps position is set to 80, the stop loss value will increase to initial stop loss value + 80 pips at the first step and to initial stop loss value + 160 pips at subsequent steps. This pattern will also repeat until the trade is stopped out.

The illustration below demonstrates the function principle and provides two examples of the operation of this stop loss trailing method.

Configuration, Stop Loss Trailing, Stepwise trailing, Function principle and example charts.png
tip

To reproduce the chart from above, you can download and use the SET file package um_eab_cslt_8_v_2_0.zip.

Please note that > (SLT) Steps position cannot be less than 100, and > (SLT) Steps size cannot exceed 100. Setting both values close to their minimum or maximum input value makes the steps more frequent. The time interval between the two steps depends on the actual price movement, which triggers the stop loss to jump to the next step.

Parameters for time based trailing

Another method for managing the stop loss is a time-based trade closure. Technically, this doesn't constitute trailing since the stop loss value remains unchanged. Instead, when this method is selected, the trade will be closed after a predetermined time, irrespective of its current performance.

Input variable within MetaTrader
(Identifier in SET file)
Default valueComment
> (SLT) Time count (<0 -> Seconds, >0 -> Bars)
(IN_nSltTimeCount)
15Positive values represent the period, measured in bars, in the currently active timeframe. On the other hand, negative values represent the period measured in seconds.

The period is determined by the input parameters > (SLT) Time count and can be utilized in two ways. Positive values represent the period measured in bars in your current timeframes. For instance, if the value is set to 10 and you're trading in the M5 timeframe, the trade will be closed after 50 minutes. Conversely, negative values represent the period measured in seconds. A value of -3600 indicates that the trade will be closed precisely 60 minutes after it's opened, while -7200 signifies a closure time of 120 minutes after the trade is opened. The following illustration demonstrates the function principle and provides two examples of positive values for > (SLT) Time count.

Configuration, Stop Loss Trailing, Time based trailing, Function principle and example charts.png
tip

To reproduce the chart from above, you can download and use the SET file package um_eab_cslt_9_v_2_0.zip.

As illustrated, the stop loss value remains unchanged in both examples.

Parameters for linear steps trailing

The linear steps stop loss trailing method increases the stop loss after each bar in the currently active timeframe, resulting in a strictly linear rise in the stop loss value.

Input variable within MetaTrader
(Identifier in SET file)
Default valueComment
> (SLT) Linear step
(IN_nSltLinearStep)
5The input value must be greater than 0. Lower values might result in a static stop loss, as the smallest price increment could be larger than the desired step size.

As is customary, the initial stop loss distance is determined by the difference between the opening price and the initial stop loss. This value represents the unitless value of 100. The only input parameter for this trailing method is the step size, defined by > (SLT) Linear step. The default value is 5, meaning the stop loss will increase by 0.5% x the initial stop loss difference after each closed bar. For instance, if the initial stop loss difference was 1000 pips, the stop loss level will increase by five pips after every closed bar. The increment might be tiny in some timeframes and initial stop loss values, so the next step could be smaller than the smallest increment for changing the stop loss.

The following illustration briefly explains the function principle and visualizes it with two examples.

Configuration, Stop Loss Trailing, Linear steps trailing, Function principle and example charts.png
tip

To reproduce the chart from above, you can download and use the SET file package um_eab_cslt_10_v_2_0.zip.

The value must be greater than 0.

Parameters for HiLo trailing

With the HiLo trailing method, the stop loss is set to the lowest local low or highest local high, depending on the direction of the trade. The lowest local low within a certain period, measured in bars, is used for long trades. The stop loss value is adjusted if a higher local low appears within the observed period. There's no limit to how often the stop loss value can change, but it can only increase for long trades. The function principle for short trade is vice versa.

Input variable within MetaTrader
(Identifier in SET file)
Default valueComment
> (SLT) HiLo period
(IN_nSltHiLoPeriod)
20The input value cannot be smaller or equal to 0.

The only variable that affects this trailing method is the observed period, defined by > (SLT) HiLo period. This value specifies the number of bars preceding the current time. The larger the value, the further the stop loss is typically from the price chart. The illustration below demonstrates the function principle and provides some examples.

Configuration, Stop Loss Trailing, HiLo trailing, Function principle and example charts.png
tip

To reproduce the chart from above, you can download and use the SET file package um_eab_cslt_11_v_2_0.zip.

As shown, all examples illustrate trades made in a long direction. For short trades, the behavior is reversed. This trailing method often aligns with previous short-term support and resistance values.