The SAR Trading System illustrates the operation of the Stop and Reversal (SAR), developed by Welles Wilder. The Expert Advisor check for presence of an open position and starts moving the stop loss with parabolic acceleration, determined by the parameters of the parabolic system.
Every time a new bar opens, the EA moves the stop loss by a value determined by the parabolic. Due to the acceleration factor, the amount, by which the stop loss is moved, increases steadily. As a result, the stop loss moves with a noticeable acceleration. The SAR system is described in more detail below.
Although Wilder conceived the SAR for reversing position at the moment the parabolic touches the current price, the proposed system uses the SAR as an effective trailing stop.
The option for opening random buy or sell positions has been provided in order to illustrate the operation of the stop loss trailing system in an EA. The EA opens random positions only if the 'Random trade toggle' switch is set to 'True'. In case the switch is set to 'false', the EA will not open positions by itself.
Parabolic system, however, remains active. That is, the EA can trail positions opened manually or by another expert.
The EA also features the ability to delay the opening of a new position by certain time. The delay time is set by the timer.
Below are the external parameter of the EA with brief comments:
Every time a new bar opens, the system must calculate a new stop loss value. For long positions the new value is calculated as:
SAR(n+1) = SAR(n) +AF x [EP - SAR(n)].
Accordingly, for short positions the new stop loss value is calculated as:
SAR(n+1) = SAR(n) - AF x [SAR(n) - EP],
Translated from Russian by MetaQuotes Software Corp.
Original code: https://www.mql5.com/ru/code/16087
The Acceleration/Deceleration Indicator (AC) measures acceleration and deceleration of the current driving force.Average Directional Movement Index (ADX)
The Average Directional Movement Index Indicator (ADX) helps to determine if there is a price trend.