Skip to content
FXNook HubBeta

Alex / Pending Order Straddle EA for MT5

MetaTrader 5Expert AdvisorMITCompiled · build 6333
AlexFirst version.build 6333v1.06 hours ago1 version
  • FXN_PendingStraddle.mq5First version.23 KB
  • FXN_PendingStraddle.ex5Compiled by the Lab with MetaEditor build 633352 KB
README

Overview

Free news and session-open straddle EA: places a buy stop and sell stop at a set time, OCO, expiry, optional trailing stop and time exit.

FXN Pending Straddle is a free, open-source Expert Advisor for MetaTrader 4 and MetaTrader 5 that places a buy stop above and a sell stop below price at a time you set, such as just before a news release or session open. The side the market breaks to is filled and the other order is removed.

How it works

  • At the placement time (server time): buy stop at Ask + distance, sell stop at Bid - distance; with a too-wide spread it retries during the placement window.
  • A distance below the broker stop or freeze level is raised to the minimum, with a message.
  • Each order has a stop loss and an optional take profit in points from its entry price.
  • OCO: once one order fills, the other is deleted on the next tick, also in the Strategy Tester.
  • Expiry: unfilled orders are deleted the set number of minutes after placement (handled by the EA, not the broker).
  • Trailing stop (optional): when the profit reaches the start distance, the stop follows price at the trailing distance, moving only forward and in steps.
  • Time exit (optional): close the trade after a set number of minutes.
  • One setup per day (also after a restart) and none while an earlier trade or order is open.
  • Lot size: risk mode sizes the lot from the stop distance, tick value and tick size so a stop-out costs the set % of balance, rounded down to the lot step. Below the minimum lot the trade is skipped with a message.

Inputs

InputDefaultWhat it does
Place hour / minute / window15 / 25 / 3Placement time (server) and minutes a late placement is allowed
Expiry / Max trade (minutes)60 / 0Delete unfilled orders / close a trade after this time (0 = off)
Distance (points)150Distance of each stop order from price
Stop loss / take profit (points)200 / 400From the entry price (take profit 0 = none)
Use trailingtrueTurn the trailing stop on or off
Trail start / distance / step (points)150 / 100 / 20When trailing starts, how far behind, minimum move
Monday ... FridaytrueDays the EA may trade
Lot mode / Fixed lot / Risk %Risk / 0.10 / 1.0Fixed lot, or a lot sized so a stop-out costs this % of balance
Magic number510601Marks this EA's trades; it only manages its own
Max spread / slippage (points)40 / 10Entry spread filter (0 = off) and allowed deviation
Order commentFXN StraddleComment on the orders

How to use it

  1. Copy FXN_PendingStraddle.mq4 to MQL4/Experts (MT4) or FXN_PendingStraddle.mq5 to MQL5/Experts (MT5) via File > Open Data Folder, then refresh the Navigator.
  2. Attach it to a chart and allow algo trading (toolbar button and the EA's own setting).
  3. Place the orders 2 to 5 minutes before the event (server time) with the distance outside the pre-news noise; on 5-digit EURUSD, 150 points = 15 pips. Turn off days without an event.
  4. Test in the Strategy Tester and on a demo account before any live use.

Good to know

  • Around major news, spreads widen, stop orders can slip a lot and a fast whipsaw can trigger both sides before the EA reacts. Test with your broker's real conditions.
  • The EA has no news calendar; you choose the time.
  • After a stop-out there is no re-entry, even if price then moves the other way.
  • Pending orders are managed by the EA, so keep the terminal running (a VPS helps) while orders are open.

Trading carries risk. Test on a demo account first; past results do not predict future results.

At a glance

What it is
A free Expert Advisor for MetaTrader 5, written in MQL5.
What it does
Free news and session-open straddle EA: places a buy stop and sell stop at a set time, OCO, expiry, optional trailing stop and time exit.
Shared by
Alex
Licence
MIT
Version
1.0 (1 Dec 2026)
Settings
24 inputs
Lab check
Compiled with MetaEditor build 6333 for MT5 on 1 Dec 2026: 0 errors, 0 warnings.
Price
Free to download

Settings read from the code

InputTypeDefaultNote
InpPlaceHourint15Hour to place the buy stop and sell stop (0-23, server time)
InpPlaceMinuteint25Minute to place the orders (0-59)
InpPlaceWindowMinint3Minutes after the set time in which late placement is still allowed
InpExpiryMinutesint60Cancel orders that have not filled this many minutes after placement
InpMaxTradeMinutesint0Close an open trade after this many minutes (0 = off)
InpDistancePointsint150Distance of each stop order from the current price (points)
InpStopPointsint200Stop loss distance from the entry price (points)
InpTargetPointsint400Take profit distance from the entry price (points, 0 = none)
InpUseTrailingbooltrueTrail the stop loss once the trade is in profit
InpTrailStartPointsint150Profit in points before trailing starts
InpTrailDistancePointsint100Distance of the trailing stop behind price (points)
InpTrailStepPointsint20Minimum stop improvement per change (points)
InpMondaybooltrueTrade on Monday
InpTuesdaybooltrueTrade on Tuesday
InpWednesdaybooltrueTrade on Wednesday
InpThursdaybooltrueTrade on Thursday
InpFridaybooltrueTrade on Friday
InpLotModeENUM_FXN_LOTSFXN_LOTS_RISKLot sizing mode
InpFixedLotdouble0.10Fixed lot (used when mode = Fixed lot)
InpRiskPercentdouble1.0Risk per trade in % of balance (used when mode = Risk %)
InpMagiculong510601Magic number (the EA only manages its own trades)
InpMaxSpreadPointsint40Max spread in points when placing the orders (0 = no limit)
InpSlippagePointsint10Max slippage (deviation) in points
InpCommentstringFXN StraddleOrder comment

How to use it

  1. Download the compiled file (or the source and compile it in MetaEditor).
  2. Put it in MetaTrader: File → Open Data Folder → MQL5 → Experts, then refresh the Navigator.
  3. Test it on a demo account before any real money.
  4. Want changes? Open a copy in your Lab and ask for them in plain words.