Forex
EA

EA: Parabolic SAR Trend Expert Advisor

Last updated 2026-07-17

An Expert Advisor (EA) is different from every other download on this site — an indicator only plots or alerts, while an EA actually sends orders on your behalf. This free EA trades a single, transparent trend-following strategy built entirely around Parabolic SAR: it enters on the classic SAR "flip," sizes its Stop Loss, Take Profit, and position automatically, and manages one position at a time. One thing sets it apart from every other EA on this site: its Stop Loss isn't ATR-based at all — it's the SAR dot itself, for reasons explained below.

How the Strategy Works

Parabolic SAR plots a series of dots that sit either above or below price, trailing the current trend. When the dots are below price, the market is read as an uptrend; when they're above price, it's read as a downtrend. A "flip" happens when price crosses through the dots and SAR jumps to the other side — this EA treats that flip as its entry signal, exactly the way the site's own Parabolic SAR lesson describes it: a flip from above price to below price suggests the downtrend just ended and a new uptrend is starting, and the mirrored flip suggests the reverse.

The EA runs Parabolic SAR with its default Step (Acceleration Factor) of 0.02 and Maximum of 0.20 — the same defaults Wilder originally used and the same ones most traders leave in place — and checks for a flip on every completed bar. It doesn't add any separate trend-strength filter on top of the flip; the flip itself, plus the risk controls covered below, is the entire signal.

Stop Loss, Take Profit, and Position Sizing

PriceTake Profit (TP)Stop Loss = SAR dotBUYDot above price (downtrend)Dot below price (uptrend)
Entry conditions: BUY when the dots flip from above price to below price — SELL on the mirrored flip — the flipped dot itself becomes the Stop Loss, trailing as new dots print

This is the section that matters most for understanding this particular EA. Every other EA on this site sizes its Stop Loss from ATR — a volatility-adaptive stop that widens on volatile pairs and tightens on calm ones. This EA does not do that, and it's not an oversight. Parabolic SAR was designed from the start to double as a volatility-adaptive trailing stop; that's literally what the "SAR" in its name stands for — Stop And Reverse. Layering ATR on top of a SAR-based system would be redundant: both are trying to answer the same question (how far away should my stop be, given current volatility?), and SAR already answers it directly, dot by dot, as part of the same calculation that produced the entry signal.

So when the EA opens a BUY on a bullish flip, the Stop Loss is placed exactly at the SAR dot value that triggered the flip — a dot that is already sitting below the entry price by a distance that reflects current volatility and how far the trend has already extended. The mirrored logic applies to a SELL: the Stop Loss sits at the SAR dot above the entry price. Take Profit is then set at a multiple of that Stop Loss distance — RiskRewardRatio, default 2.0 — so a 2.0 setting means the target is twice as far from entry as the stop, keeping every trade's risk and reward in a fixed, known proportion regardless of how wide or narrow that particular SAR-based stop happens to be.

Position size is calculated the same way as every other EA on this site: a RiskPercent of account balance (default 1.0%) divided by the Stop Loss distance, converted through the symbol's tick value and normalized to the broker's lot step — the exact worked-example method from Risk Management Basics. A wider SAR-based stop produces a smaller lot size, and a tighter one produces a larger lot size, so the dollar risk per trade stays consistent even though the stop distance itself varies from trade to trade. A UseFixedLot input with a FixedLotSize value is available as an escape hatch for traders who'd rather trade a constant lot size regardless of risk.

Entry Conditions

  • BUY — the Parabolic SAR dots flip from above price to below price on a newly completed bar; the Stop Loss is placed at that flipped dot.
  • SELL — the Parabolic SAR dots flip from below price to above price on a newly completed bar; the Stop Loss is placed at that flipped dot.

The EA evaluates these conditions once per new bar only (tracked against the time of the current bar's open), never on every tick, so a single flip can't fire multiple trades within the same candle. It opens at most one position at a time, counted and filtered by its own magic number, so it never confuses a position it opened with one you opened manually or one belonging to a different EA on the same account. Before opening anything, it also checks the current spread against MaxSpreadPoints and skips the entry entirely if the market is too illiquid at that moment.

Parameters

  • Step (default 0.02) — the Parabolic SAR Acceleration Factor; controls how quickly the dots accelerate toward price as the trend extends. A larger value hugs price tighter and flips (and exits) sooner; a smaller value trails looser.
  • Maximum (default 0.20) — the cap on how fast the acceleration factor can grow, preventing the dots from ever catching up to price too aggressively in a long-running trend.
  • RiskRewardRatio (default 2.0) — Take Profit distance = Stop Loss distance (from the SAR dot) × this ratio.
  • RiskPercent (default 1.0) — percentage of account balance risked per trade, used to calculate lot size against the SAR-based Stop Loss distance. Ignored if UseFixedLot is enabled.
  • UseFixedLot (default false) — when enabled, trades a constant lot size instead of calculating one from RiskPercent.
  • FixedLotSize (default 0.01) — the lot size used when UseFixedLot is enabled.
  • MaxSpreadPoints (default 30) — skips new entries while the spread is wider than this, the same concern covered in Spread and Slippage.
  • EnableTrading — a master on/off switch, useful for pausing the EA without removing it from the chart.
  • MagicNumber (default 20260722) — tags every order this EA places so its position-counting and management logic never touches trades opened manually or by a different EA.

Notice what's missing compared to the site's other EAs: there is no ATRPeriod and no ATRMultiplier here. That's not a simplification or an oversight — it's the direct consequence of the design choice explained above and in the next section.

Why This EA Doesn't Use ATR

Every other EA on this site — ea-trend-following included — calculates its Stop Loss as ATRMultiplier × ATR, a fixed distance recalculated fresh at the moment each trade opens and then left alone (or, at best, manually trailed) for the rest of the trade's life. This EA works differently on purpose, and the difference is worth walking through concretely.

ATR measures average volatility over a lookback period and gives you one number: how far away, in current market conditions, a stop "should" be at this instant. Parabolic SAR does something similar but goes a step further — it produces a whole sequence of stop levels, one per bar, that automatically tightens as a trend matures. That's the entire mechanical idea behind the indicator: an early, young trend gets a wide berth so normal volatility doesn't shake you out, and a late, extended trend gets an aggressively tightening leash that locks in more of the open profit the longer the move runs. An ATR-based stop, by contrast, is usually set once at entry and doesn't reshape itself bar-by-bar in response to how far the trend has already traveled — it would need a separate trailing routine layered on top to do what SAR already does natively.

That's the practical implication for this specific EA: because the Stop Loss is defined as "the current SAR dot" rather than a static ATR-derived distance frozen at entry, a trader who chooses to manage the trade manually (or a future version of this EA that trails the stop bar-by-bar) gets a tightening stop "for free" — no extra ATR recalculation, no separate trailing-stop module, no second indicator to keep in sync with the first. As price extends further into the trend and new SAR dots print closer and closer to price each bar, the theoretical stop distance shrinks on its own, purely as a byproduct of the same calculation that generated the entry signal in the first place. Running ATR alongside SAR here wouldn't make the stop meaningfully better — it would just be a second, disagreeing opinion on a question SAR has already answered, and reconciling the two would add complexity without adding protection.

Installation and Setup

EAs install into a different folder than indicators — this is the step people miss most often.

  1. Download the file below for your platform.
  2. Open MetaTrader → click FileOpen Data Folder.
  3. Place the file in MQL4/Experts (MetaTrader 4) or MQL5/Experts (MetaTrader 5) — not the Indicators folder.
  4. Restart MetaTrader, then drag the EA from the Navigator window onto a chart.
  5. Enable AutoTrading (MT4) or Algo Trading (MT5) in the toolbar — the EA will not place any trades while this is off, even if it's attached to a chart.
  6. Review and adjust the input parameters in the EA's settings dialog before confirming.

A Word of Caution

Test on a demo account first, across different market conditions, before risking real money — past performance, in backtests or live, never guarantees future results. No strategy, automated or manual, wins every trade, and this EA can and will lose money on individual trades. Parabolic SAR in particular whipsaws badly in ranging or choppy markets: because it's always positioned on one side of price and always flips when crossed, a sideways market forces it to flip back and forth repeatedly, generating a steady drip of false entries and small losses with no trend-strength filter to sit those periods out. Consider combining it with a read of trend vs range or an ADX filter of your own before enabling it on a live account. Both files are source code — open and review them fully, and understand what every parameter does, before using it. This content is general education, not personalized investment advice.

Download the EA

How to Install — MetaTrader 4

  1. Download the parabolic-sar-trend-ea.mq4 file below.
  2. Open MetaTrader 4 → click FileOpen Data Folder.
  3. Place the file in the MQL4/Experts folder.
  4. Restart MetaTrader 4, then drag the EA from the Navigator window onto the chart.

How to Install — MetaTrader 5

  1. Download the parabolic-sar-trend-ea.mq5 file below.
  2. Open MetaTrader 5 → click FileOpen Data Folder.
  3. Place the file in the MQL5/Experts folder.
  4. Restart MetaTrader 5, then drag the EA from the Navigator window onto the chart.

Both files are source code — open and review the full code before using it, for your own safety.

Download parabolic-sar-trend-ea.mq4

For MetaTrader 4 — this is source code (.mq4), open and review it fully before using it.

Download File

Download parabolic-sar-trend-ea.mq5

For MetaTrader 5 — this is source code (.mq5), open and review it fully before using it.

Download File