Skip to content

Free MT5 Expert Advisor

NY Opening Range EA

MT5 Expert Advisor that brackets the New York opening range of N minutes with stop orders and closes the trade at a set time.

Sessionsv1.0MetaTrader 5 (MQL5) Compiles with 0 errors Stop-loss on every trade
Strategy
Records the high and low of the first N minutes after the New York open, then places a buy stop above and a sell stop below that range. The first fill cancels the other order and any open trade is closed at the exit time.
Risk model
1% of balance per trade (configurable), stop-loss inside or beyond the opening range on every order, one position and one setup per day

What it does

The first minutes after the New York cash open are often among the most active of the day for US indices, the dollar and gold. NY Opening Range EA measures the high and low of that opening period and trades a breakout from it, then exits by a fixed time so no trade is held overnight.

How it works

Times are entered in GMT and converted with the server offset input. The default 13:30 GMT matches the 09:30 New York stock open during US daylight time; use 14:30 GMT in US winter.

  1. Range: the high and low of the M1 bars from the open to open + 30 minutes. At least half of those minutes must have M1 bars.
  2. Range filter: 50 to 600 points.
  3. Orders: at the first chart bar after the range ends, a buy stop at range high + 10 points and a sell stop at range low − 10 points.
  4. Stops: at the opposite order's entry by default, or at the range midpoint. Target: 1.5 × the stop distance.
  5. One trade: a fill deletes the other order; if a gap fills both, the newer position is closed.
  6. Entry window: orders still unfilled 90 minutes after the range ends are deleted.
  7. Time exit: an open trade is closed at 19:30 GMT, or on the next day if it is still open then.

One setup is made per GMT day and the deal history is checked, so a restart does not add a second trade. The forex trading sessions lesson covers how the New York session overlaps with London.

How to use it

Use an M1 to M15 chart, preferably one shorter than the range length. Index CFDs and gold usually need wider point filters than EURUSD; check the typical opening range on your symbol first. Remember to update both the open hour and the server offset when US or broker clocks change. The Forex Market Hours tool helps you check the session times.

Settings

InputDefaultWhat it changes
Server GMT offset2Converts GMT times to server time
NY open hour / minute (GMT)13 / 30Start of the opening range
Opening range length (minutes)30Range duration
Entry window (minutes)90Pending-order lifetime
Time exit / Exit time (GMT)true / 19:30Forced exit
Min / Max range (points)50 / 600Range filter
Entry buffer (points)10Order distance beyond the range
Stop-loss placementOpposite sideStop location
Reward:risk target1.5Take-profit, 0 disables it
Risk per trade / Fixed lots1.0% / 0Position sizing
Max spread (points)30Spread filter
Break-even / Trailingon / offStop management

Limitations

US data releases often land shortly before or near the open and can produce sharp two-way moves that trigger an order and then hit its stop. Spreads can widen around the open. Daylight-saving changes in the US, UK and at your broker must be handled manually. Results vary strongly between symbols, so point-based filters need tuning for each one.

Before you run it live

Confirm the server offset and open time, then test it in the Strategy Tester with real-tick data, since stop-order fills depend on intrabar prices. Run it on a demo account through at least one clock change and keep the risk per trade small. Past behavior does not guarantee future results.

Key inputs

Key inputs of NY Opening Range EA
InputDefaultDescription
Broker server time minus GMT (hours)2Converts GMT times to your broker's server time.
New York open hour (GMT; 13 in US summer, 14 in US winter)13Hour of the reference open in GMT.
New York open minute (GMT)30Minute of the reference open.
Opening range length (minutes)30How long the range is measured after the open.
Pending orders live this long after the range ends90Entry window in minutes; unfilled orders are deleted after it.
Exit hour / Exit minute (GMT)19 / 30Time exit for an open trade.
Stop-loss placementOpposite side of the rangeOpposite side of the range or its midpoint.
Take-profit as a multiple of the stop (0 = none)1.5Reward-to-risk target.

Educational tools, not advice. Automated trading can lose money quickly. Indicators and Expert Advisors describe price; they do not predict it, and past behaviour does not guarantee future results. Test everything on a demo account first and never risk money you cannot afford to lose. See our disclaimer.

Keep exploring

Related mt5 expert advisors