# Pending Order Straddle EA for MT5

> 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.

## 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
- Page: https://hub.fxnook.com/pending-order-straddle-ea-for-mt5
- Download (compiled): https://hub.fxnook.com/download/53562514-7873-4af3-b342-024bb0a31d34/compiled
- Download (source): https://hub.fxnook.com/download/53562514-7873-4af3-b342-024bb0a31d34/source

## About

**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

| Input | Default | What it does |
|---|---|---|
| Place hour / minute / window | 15 / 25 / 3 | Placement time (server) and minutes a late placement is allowed |
| Expiry / Max trade (minutes) | 60 / 0 | Delete unfilled orders / close a trade after this time (0 = off) |
| Distance (points) | 150 | Distance of each stop order from price |
| Stop loss / take profit (points) | 200 / 400 | From the entry price (take profit 0 = none) |
| Use trailing | true | Turn the trailing stop on or off |
| Trail start / distance / step (points) | 150 / 100 / 20 | When trailing starts, how far behind, minimum move |
| Monday ... Friday | true | Days the EA may trade |
| Lot mode / Fixed lot / Risk % | Risk / 0.10 / 1.0 | Fixed lot, or a lot sized so a stop-out costs this % of balance |
| Magic number | 510601 | Marks this EA's trades; it only manages its own |
| Max spread / slippage (points) | 40 / 10 | Entry spread filter (0 = off) and allowed deviation |
| Order comment | FXN Straddle | Comment 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.

## Settings (inputs)

| Input | Type | Default | Note |
|---|---|---|---|
| InpPlaceHour | int | 15 | Hour to place the buy stop and sell stop (0-23, server time) |
| InpPlaceMinute | int | 25 | Minute to place the orders (0-59) |
| InpPlaceWindowMin | int | 3 | Minutes after the set time in which late placement is still allowed |
| InpExpiryMinutes | int | 60 | Cancel orders that have not filled this many minutes after placement |
| InpMaxTradeMinutes | int | 0 | Close an open trade after this many minutes (0 = off) |
| InpDistancePoints | int | 150 | Distance of each stop order from the current price (points) |
| InpStopPoints | int | 200 | Stop loss distance from the entry price (points) |
| InpTargetPoints | int | 400 | Take profit distance from the entry price (points, 0 = none) |
| InpUseTrailing | bool | true | Trail the stop loss once the trade is in profit |
| InpTrailStartPoints | int | 150 | Profit in points before trailing starts |
| InpTrailDistancePoints | int | 100 | Distance of the trailing stop behind price (points) |
| InpTrailStepPoints | int | 20 | Minimum stop improvement per change (points) |
| InpMonday | bool | true | Trade on Monday |
| InpTuesday | bool | true | Trade on Tuesday |
| InpWednesday | bool | true | Trade on Wednesday |
| InpThursday | bool | true | Trade on Thursday |
| InpFriday | bool | true | Trade on Friday |
| InpLotMode | ENUM_FXN_LOTS | FXN_LOTS_RISK | Lot sizing mode |
| InpFixedLot | double | 0.10 | Fixed lot (used when mode = Fixed lot) |
| InpRiskPercent | double | 1.0 | Risk per trade in % of balance (used when mode = Risk %) |
| InpMagic | ulong | 510601 | Magic number (the EA only manages its own trades) |
| InpMaxSpreadPoints | int | 40 | Max spread in points when placing the orders (0 = no limit) |
| InpSlippagePoints | int | 10 | Max slippage (deviation) in points |
| InpComment | string | FXN Straddle | Order comment |

Tags: straddle, news-trading, pending-orders, oco, trailing-stop, expert-advisor

Shared code is the author's work, not financial advice. Test on a demo account first.
