Loading…

Parabolic SAR Flip EA

Parabolic SAR trailing-and-reverse is one of the oldest mechanical systems in retail trading. It is included here as a clean, honestly-labelled reference implementation: one indicator, one rule, no hidden filters, so a trader can see exactly how it behaves before deciding whether to build on it. The EA is always in the market once it has taken its first position: on every closed bar it checks whether the SAR dot has crossed to the other side of price since the previous bar, and if it has, closes whatever position it is holding and opens the opposite one. The dot itself becomes the new position's protective stop, because trailing the stop with the indicator is the entire point of using Parabolic SAR in the first place. The one deliberate safety check that goes beyond the bare textbook version: a fresh flip can put the dot inside the broker's minimum stop distance, especially on a fast-moving symbol. Rather than send an order MetaTrader would reject, the EA logs it and waits for the next tick's SAR value to clear the distance - the flip is not lost, only delayed by however long the broker's restriction takes to clear. Position sizing can run as a fixed lot or, with InpUseRiskSizing on, as a percentage of equity risked to the SAR-derived stop distance. The risk calculation uses MODE_TICKVALUE and MODE_TICKSIZE rather than a hardcoded contract size, so it prices correctly on gold, indices and JPY crosses as well as plain FX pairs. Notes and limitations - This is a textbook reversal system with no trend or volatility filter. In a ranging market it will flip repeatedly and pay the spread each time - that is the well-documented weakness of trading raw Parabolic SAR, not a bug in this implementation. - Signals are evaluated once per closed bar, not on every tick, so the chart period you attach it to controls how often it can react. - One position at a time, tracked by InpMagicNumber. It will not manage or interfere with trades opened manually or by another EA. - Requires AutoTrading enabled and IsTradeAllowed() true; if trading is disabled the EA logs it and skips the flip rather than queuing it.

Expert advisor · MT5 · v1.0 · Free

About Parabolic SAR Flip EA

Parabolic SAR Flip EA is an expert advisor (trading robot) for MetaTrader 5 based on Parabolic SAR. It can size trades from your balance and risk percent. It has 10 settings, such as Sar step, Sar maximum and Use risk sizing. MQL source code included.

Files in the download: SarFlipEa.ex5, SarFlipEa.mq5, SarFlipEa.txt.

Trading robots can lose money. Check every setting and test on a demo account before using real funds.

Settings

SettingDefaultWhat it does
Sar step0.02SAR step (acceleration factor)
Sar maximum0.2SAR maximum acceleration
Use risk sizingfalseSize by percent risk instead of a fixed lot
Risk percent1.0Percent of equity risked per trade, when risk sizing is on
Fixed lots0.10Lot size when risk sizing is off, or as a fallback
Take profit pips0Optional take profit distance, in pips (0 = none, exit only on next flip)
Magic number20260601Magic number for orders opened by this EA
Slippage pips3Slippage tolerance, in pips
Max retries5Attempts per trade action before giving up
Retry wait ms500Pause between attempts, milliseconds

How to install

  1. Download the ZIP from your PolyMaria library and unzip it.
  2. In MetaTrader 5 open File → Open Data Folder, then go to MQL5 → Experts.
  3. Copy the .mq5 file(s) there. Put any .mqh files in MQL5 → Include.
  4. Open the .mq5 file in MetaEditor and press Compile (F7) if MetaTrader does not show it.
  5. Drag the expert advisor from the Navigator onto a chart, check the settings, allow Algo/Auto Trading and press OK.
  6. Test it first on a demo account or in the Strategy Tester.

Download the PDF guide

Tags: Parabolic SAR · Trailing Stop & Break-even · Risk & Lot Size · MT5 Expert Advisor · MQL5 Source Code

Expert advisors (EA) for MT4 & MT5 · PolyMaria