AutoPilot FX EA
An ATR-based breakout straddle bot for MetaTrader 5. It brackets price with a Buy Stop and a Sell Stop sized from current volatility, follows whichever way the market breaks, cancels the other side, and re-arms once the trade closes — with an adjustable daily loss limit and built-in safety warnings.
What it does
Stop-and-reverse breakout logic, driven by volatility — or by price percentage — rather than a fixed distance.
Volatility-sized straddle
Distance from price for both pending orders is ATR × multiplier by default, so the bracket widens in fast markets and tightens in quiet ones.
Breakout direction
Whichever stop order triggers first rides the breakout. Each entry carries a tight Stop Loss and Take Profit, in points or in % of price.
OCO behaviour
When one side fills, the opposite pending order is cancelled automatically. Only one straddle (two pending orders) is ever active — no grid, no martingale.
Auto re-arm & re-center
After a trade closes on SL or TP, a fresh straddle is placed around the new price. If price drifts off without triggering, the straddle re-centers.
Key features
Safety and transparency are built in, not bolted on.
Auto mode — works on anything
Default setting. SL, TP, and straddle distance are all multiples of the instrument's own live ATR, and the spread filter compares live spread to live ATR too — so nothing is a fixed number that a given instrument could outgrow. Confirm and go, on forex, crypto, metals, or an index.
Category presets, if you'd rather
Set InpPreset to Forex, Crypto, or Metals / Index for a fixed bundle tuned to that category instead of Auto's live calibration. Pick Custom to control every number by hand.
OCO straddle engine
Buy Stop above, Sell Stop below; first fill wins, the other order is pulled.
Fixed-points or %-of-price mode
Under Custom mode, calculate SL, TP, and straddle distance as raw points off an ATR reading, or as a percentage of price — useful for instruments where a fixed point count doesn't scale, like crypto pairs.
Adjustable daily loss limit
Halts trading for the rest of the day once losses hit a cap — a percentage of the day-start balance or a fixed amount. Optionally closes any open position when the limit is reached.
Spread filter
Skips placing new orders when the spread is wider than your threshold, to avoid entering during news spikes.
Optional chop/trend filter
Off by default. InpUseChopFilter pauses placing a new straddle when live ADX reads below InpMinADX — the ranging conditions this strategy tends to whipsaw in. Only delays arming a fresh straddle; never touches a trade that's already open.
Input sanity-check warnings
On load, the EA checks your settings against recommended safe ranges and raises an Alert plus a detailed log explanation for anything outside them. It still runs with your values — the warning is informational.
On-chart dashboard
Live status panel showing current state, today's P/L, and whether the daily limit has been hit.
Single self-contained file
One .mq5, no dependencies, no DLLs. Compile in MetaEditor and run.
Installation
About two minutes in MetaTrader 5.
- Download
AutoPilotFX_EA.mq5from the button above. - In MetaTrader 5, open File → Open Data Folder.
- Copy the file into
MQL5/Experts/. If you're updating an existing copy, delete the old.mq5/.ex5first so MT5's Navigator doesn't end up listing two versions side by side. - Back in MT5, right-click Expert Advisors in the Navigator and choose Refresh. Then right-click the EA itself → Modify → press F7 in MetaEditor to compile (confirm "0 errors, 0 warnings").
- Drag AutoPilotFX_EA onto a chart (tested on EURUSD) and tick Allow Algo Trading in the dialog's Common tab. You also need the global “Algo Trading” button in MT5's top toolbar switched on — both have to be enabled, or every order gets silently rejected with “auto trading disabled by client”.
- In the Inputs tab,
InpPresetdefaults to Auto — it self-calibrates to whatever chart it's on, so you can just confirm and go. Switch it to Forex / Crypto / Metals / Index for a fixed category bundle instead, or Custom to set each value yourself — see the Key Inputs table below.
Key inputs
InpPreset defaults to Auto, which works out of the box — the table below is for anyone who wants a fixed category bundle instead, or picks Custom to set every value themselves.
| Preset | Use for | What it sets |
|---|---|---|
| Auto (default) | anything — no need to know what it is | ATR-Relative mode: SL/TP/distance are all multiples of this instrument's own live ATR; spread filter compares live spread to live ATR too. Nothing hard-coded, nothing to outgrow. |
| Forex | EURUSD, GBPUSD, AUDJPY, etc. | Fixed Points mode, ATR × 1.0 distance, 80/120pt SL/TP, 200pt max spread |
| Crypto | BTCUSD, ETHUSD, etc. | Percentage mode, 1.5%/2.5% SL/TP, 1.0% distance, 3000pt max spread |
| Metals / Index | XAUUSD, US30, etc. | Percentage mode, 0.5%/0.8% SL/TP, 0.3% distance, 500pt max spread |
| Custom | anything, hand-tuned | Uses every detailed input in the table below, unchanged |
Why Auto is the default: the category presets are still a human guess about what's "typical" for forex, crypto, etc. — usually fine, but a specific pair can sit outside that norm (an unusually wide spread right now, say). Auto never hard-codes a number at all: everything recalculates from this instrument's own live ATR and spread continuously, so there's no preset to pick wrong and nothing that can quietly stop fitting later.
These are sane starting points, not tuned or guaranteed settings — validate on a demo account first, same as any default.
| Input (Custom preset only, unless noted) | Default | Notes |
|---|---|---|
InpCalcMode | Fixed Points | Fixed Points (ATR distance), Percentage of Price, or Auto (ATR-Relative) |
InpATRPeriod | 14 | ATR period — Fixed Points or Auto mode |
InpATRTimeframe | M15 | Timeframe used for the ATR reading — Fixed Points or Auto mode |
InpATRMultiplier | 1.0 | Distance from price = ATR × this — Fixed Points or Auto mode |
InpSLPoints | 80 | Stop loss, in points — Fixed Points mode |
InpTPPoints | 120 | Take profit, in points — Fixed Points mode |
InpSLPercent | 0.07 | Stop loss, % of entry price — Percentage mode |
InpTPPercent | 0.11 | Take profit, % of entry price — Percentage mode |
InpDistancePercent | 0.05 | Straddle distance, % of current price — Percentage mode |
InpSLATRMultiplier | 0.9 | Stop loss = ATR × this — Auto/ATR-Relative mode |
InpTPATRMultiplier | 1.5 | Take profit = ATR × this — Auto/ATR-Relative mode |
InpMaxSpreadATRFactor | 0.25 | Skip placing orders if spread exceeds ATR × this — Auto/ATR-Relative mode |
InpLotSize | 0.01 | Lot size |
InpMagicNumber | 260826 | Unique EA identifier |
InpMaxSpreadPoints | 200 | Max allowed spread (points) — Fixed Points or Percentage mode |
InpUseChopFilter | false | Pause new straddles when the market looks like it's ranging (ADX-based) |
InpADXPeriod | 14 | ADX period — chop filter |
InpADXTimeframe | M15 | Timeframe used for the ADX reading — chop filter |
InpMinADX | 20.0 | Minimum ADX to allow a new straddle; below this = treated as ranging/chop |
InpUseDailyLossLimit | true | Enable / disable the daily cap |
InpLimitIsPercent | true | % of day-start balance vs fixed amount |
InpDailyLossPercent | 3.0 | Recommended max: 5% |
InpDailyLossAmount | 20.0 | Used only if InpLimitIsPercent = false |
InpCloseOpenOnLimitHit | true | Close open position when the limit hits |
Disclaimer — read before use
- Use a demo account first. Run the EA on a demo account until you understand its behaviour in your market and on your broker's conditions.
- No guarantee of profit. Straddle bots whip-saw and lose repeatedly in ranging or choppy markets, and only profit on genuine breakouts. Past or simulated results do not predict future results.
- The daily loss limit is a safety brake, not a promise. It caps losses within a single session — it does not make the strategy profitable.
- Not financial advice. This software is provided for educational and informational purposes only. Nothing here is a recommendation to trade any instrument. Trading forex and CFDs carries a high risk of loss and is not suitable for everyone. You are solely responsible for any use of this EA and any resulting losses.
- No warranty. The software is provided “as is”, without warranty of any kind.