EA_RangeBreakout

 

[MQL4] 5-Minute Scalping EA Strategy: Exploiting 4-Hour Range Fakeouts

This article provides a comprehensive breakdown of the trading logic and external input settings for an Automated Expert Advisor (EA) designed for MetaTrader 4. The strategy focuses on trading fakeouts (liquidity sweeps) occurring around the initial 4-hour range formed at the start of the trading day (00:00–04:00 GMT).


1. Trading Strategy Overview

The initial range established at the beginning of the trading day acts as a key area where institutional liquidity accumulates. When price briefly breaks beyond these high/low boundaries and rapidly reverts back into the range, it signals a false breakout (Liquidity Sweep). This EA captures these momentum shifts by entering trades in the direction of the mean reversion.

■ Key Parameters

  • Recommended Timeframe: 5-Minute Chart (M5)
  • Reference Range: The Highest High and Lowest Low of the day’s first 4-hour candle (00:00–04:00 GMT), automatically calculated based on your broker’s GMT offset.
 [ 4-Hour Range High (00:00-04:00 GMT) ] ──────────┐
                                                   │ ← M5 Body Breakout + Close Back Inside (SELL)
 ──────────────────────────────────────────────────┘
                                                   ┌ ← M5 Body Breakout + Close Back Inside (BUY)
 [ 4-Hour Range Low  (00:00-04:00 GMT) ] ──────────┘

2. Entry and Exit Rules (SL / TP)

① BUY Entry Setup

  1. The M5 candle closes below the 4-hour range low (candlestick body breakout).
  2. Following the breakout, an M5 candle closes back above the range low, re-entering the range. A BUY position is opened at the market on the open of the next bar.
  3. Stop Loss (SL): Set at the Lowest Price (Low) reached during the breakout phase.
  4. Take Profit (TP): Calculated automatically based on the risk distance (entry price to SL) multiplied by the specified Risk/Reward Ratio.

② SELL Entry Setup

  1. The M5 candle closes above the 4-hour range high (candlestick body breakout).
  2. Following the breakout, an M5 candle closes back below the range high, re-entering the range. A SELL position is opened at the market on the open of the next bar.
  3. Stop Loss (SL): Set at the Highest Price (High) reached during the breakout phase.
  4. Take Profit (TP): Calculated automatically based on the risk distance (entry price to SL) multiplied by the specified Risk/Reward Ratio.

3. External Input Parameters Guide

Below is a summary of the configurable input parameters available in the EA’s settings panel:

Parameter Name Default Value Description & Guidelines
InpLotSize 0.1 Position Lot Size
Sets a fixed order lot size. Adjust according to your account balance and risk management plan.
InpRiskRewardRatio 2.0 Risk/Reward Ratio (TP / SL)
Multiplier for Take Profit relative to Stop Loss distance. A value of 2.0 sets a 1:2 Risk-to-Reward ratio.
InpSlipperage 3 Maximum Slippage (pips)
Maximum price slippage allowed when executing orders. For volatile assets like Gold (XAUUSD), increasing this to 5–10 is recommended.
InpMagicNumber 20260924 Magic Number
Unique identifier for the EA’s trades. Use distinct numbers when running the EA across multiple currency pairs simultaneously.
InpGMTOffset 2 Broker GMT Offset
Enter your broker’s GMT offset (e.g., enter 2 for GMT+2 in Winter, or 3 for GMT+3 in Summer). The EA automatically maps 00:00–04:00 GMT to server time.

4. Configuring GMT Offset Examples

Most Forex brokers (e.g., XM, OANDA, TitanFX) operate on GMT+2 in Winter and GMT+3 in Summer. Simply set InpGMTOffset to match your broker’s clock:

  • Broker is GMT+2 (Winter): Set InpGMTOffset = 2
  • Broker is GMT+3 (Summer): Set InpGMTOffset = 3

5. Key Operational Tips

  • Chart Timeframe Verification: Attach this EA exclusively to an M5 (5-Minute) chart. The EA includes a built-in safety check and will halt execution on other timeframes.
  • Spread Considerations: Because Stop Losses are placed tight to recent swing highs/lows, wide spreads or high-impact news events may cause premature stop-outs. This strategy performs best on major pairs with low spreads (e.g., EURUSD, USDJPY) or Gold (XAUUSD).

Download EA

Leave a Reply

Your email address will not be published. Required fields are marked *