Skip to content

Free MT5 Expert Advisor

Parabolic SAR EA

MT5 Expert Advisor that trades Parabolic SAR flips with an EMA trend filter, placing and trailing the stop-loss at the SAR.

Trendv1.0MetaTrader 5 (MQL5) Compiles with 0 errors Non-repainting signals Stop-loss on every trade
Strategy
Buys when the Parabolic SAR flips below price while the close is above the 100 EMA, and sells when it flips above price while the close is below the EMA. The stop-loss is placed at the SAR and trails it.
Risk model
1% of balance per trade (configurable), stop-loss on every order, one position at a time

What it does

The Parabolic SAR EA trades Welles Wilder's stop-and-reverse indicator. When the SAR dots move from above price to below it, the market may be turning up; the EA buys if the longer-term EMA agrees. The opposite flip triggers sells.

The SAR is also a natural trailing stop: it moves toward price faster as the trend extends. The EA uses it both for the initial stop-loss and for trailing.

How it works

On each new bar the EA reads MetaTrader's Parabolic SAR (0.02, 0.20) and a 100-period EMA.

  • Direction: SAR below the close means up; SAR above the close means down.
  • Buy: direction is up on the last closed bar and was down on the bar before, and that close is above the 100 EMA. Filtered flips are logged.
  • Sell: the mirror image with the close below the EMA.
  • Stop-loss: the SAR value of the signal bar (plus an optional buffer). Signals with a SAR more than 3 x ATR(14) away are skipped.
  • Trailing: on every tick the stop moves to the last closed bar's SAR if that improves it.
  • Exit: if the SAR flips against the position at a bar close, the position is closed. No fixed target by default.

How to use it

The Parabolic SAR is responsive, so this EA is best in markets that make clean directional runs, for example GBPUSD or gold on H1 and H4 during busy sessions. The EMA filter keeps it from buying every flip in a downtrend.

A smaller acceleration step gives the trade more room; a larger one trails tighter. See the stop-loss glossary entry for why a fixed invalidation point matters.

Settings

InputDefaultWhat it changes
SAR acceleration step0.02How fast the SAR accelerates toward price.
SAR maximum acceleration0.20Upper limit of the acceleration factor.
Trend filter EMA period100Flips are taken only on the matching side of this EMA.
Take-profit (R multiple)0.0Optional target; 0 lets the SAR trail manage the exit.
Maximum stop (x ATR)3.0Skips the flip if the SAR is too far from price.
Use trailing stoptrueMoves the stop to the SAR on each closed bar.
Extra stop buffer (points)0Places the stop slightly beyond the SAR.
Exit on fliptrueCloses the trade when the SAR flips against it.
Risk per trade (% of balance)1.0Share of balance risked between entry and stop.
Fixed lots0Fixed volume instead of risk %; 0 = risk-based.
Maximum spread (points)20Skips signals when the spread is wider; 0 = off.
Trading start / end hour7 / 20Server-time window for new trades; equal values = 24 hours.
Move stop to break-eventrueStop to entry + 20 points once profit reaches 1R.
Magic number2611009Identifies this EA's trades.

Limitations

  • In sideways markets the SAR flips constantly; the EMA filter helps but does not remove these losses.
  • The SAR tightens quickly and can stop out a trend on a normal pullback.
  • With no fixed target, profits depend on trends lasting long enough for the trail to lag behind them.
  • A wide SAR after a fast move can push the stop beyond the ATR cap, so the trade is skipped.

Before you run it live

Test on a demo account and in the MetaTrader 5 Strategy Tester over several years first. No backtest results are published for this EA, and any test describes the past only.

  • Match the spread limit and trading hours to your broker's spreads, stop level and session times, and include commission and swap in tests.
  • Start with 1% risk or less and check the lot sizes in the Experts log; the Position Size Calculator is a useful cross-check.
  • Use a different magic number on each chart, and keep the terminal (or a VPS) running so stops are managed.

Run the Strategy Tester with 'Every tick based on real ticks' if your broker provides it, since trailing behavior depends on tick data.

Key inputs

Key inputs of Parabolic SAR EA
InputDefaultDescription
SAR acceleration step0.02How fast the SAR accelerates toward price.
SAR maximum acceleration0.20Upper limit of the acceleration factor.
Trend filter EMA period100Flips are taken only on the matching side of this EMA.
Take-profit (R multiple)0.0Optional target; 0 lets the SAR trail manage the exit.
Maximum stop (x ATR)3.0Skips the flip if the SAR is too far from price.
Use trailing stoptrueMoves the stop to the SAR on each closed bar.

Educational tools, not advice. Automated trading can lose money quickly. Indicators and Expert Advisors describe price; they do not predict it, and past behaviour does not guarantee future results. Test everything on a demo account first and never risk money you cannot afford to lose. See our disclaimer.

Keep exploring

Related mt5 expert advisors