Download MetaTrader 5

Watch how to download trading robots for free

Interesting script?
So post a link to it -
let others appraise it

You liked the script? Try it in the MetaTrader 5 terminal

2016.09.19 12:37

SAR Trading System - expert for MetaTrader 5

| English Русский 中文 Español Deutsch 日本語 Português

votes: 13

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.

EA moves stop-loss behind the price with acceleration.

SAR parabolic sytem could be very efficient in profit taking.

Below are the external parameter of the EA with brief comments:

  • Initial Stop-loss (points) — initial stop loss value (before the start of the parabolic trailing).
  • SAR acceleration factor increment step — increment of the parabolic acceleration factor (see description below).
  • SAR acceleration factor max. value — maximum value of parabolic acceleration factor (see description below).
  • Random trade toggle — toggle random position opening (true — activate the ability to perform deals manually).
  • Timer frequency (sec) — delay before opening a new deal.

EA uses four input parameters.

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],


  • SAR(n+1) — the stop loss level at the new (n+1) bar,
  • SAR(n) — the stop loss level at the previous (n) bar,
  • EP — (extremum point) — the new maximum (for a long position) or minimum (for a short position) of the price, recorded since the moment the trailing stop started,
  • AF — (acceleration factor) — the coefficient increasing at a constant step (increment of the acceleration factor) on every bar, where the price reaches a new extremum (extremum point). The acceleration factor increases until it reaches the maximum value.

Translated from Russian by MetaQuotes Software Corp.
Original code:

Exp_Volume_Weighted_MA_StDev Exp_Volume_Weighted_MA_StDev

Trading system based on Volume_Weighted_MA_StDev indicator signals.

Volume_Weighted_MA_Cloud_HTF Volume_Weighted_MA_Cloud_HTF

The Volume_Weighted_MA_Cloud indicator with the timeframe selection option available in input parameters.

RAVI_Histogram_HTF RAVI_Histogram_HTF

The RAVI_Histogram indicator with the timeframe selection option available in input parameters.

FloatPivot FloatPivot

Another alternative to the Bollinger Bands® channel with colored inner area of the channel.