Build a Session Breakout EA for MT5 (EURUSD) — EXACTLY as below. No changes to logic.
but make it work on all pairs
double slPips, tpPips;
if (AssetType == "Forex") { slPips = 20; tpPips = 60; }
if (AssetType == "GBPUSD") { slPips = 25; tpPips = 75; }
if (AssetType == "NAS100") { slPips = 30; tpPips = 90; }
if (AssetType == "US30") { slPips = 40; tpPips = 120; }
if (AssetType == "Gold") { slPips = 150; tpPips = 450; }
but optimize it for eurusd
================================================================
CORE STRATEGY
================================================================
- Trade ONLY at London Open: 08:00–08:05 UTC
- Breakout of Asian Session Range (00:00–07:59 UTC)
- Entry: 5M candle CLOSES outside Asian High/Low
- Volume Filter: Breakout candle volume > 2× 20-period average
- Risk: 0.5% of account per trade
- Option: Manual lot size override (input)
- SL: 20 pips beyond breakout level
- TP: 1:3 RR (60 pips target)
- Max 1 trade per day
- Skip: NFP, ECB Rate, FOMC, CPI, bank holidays
================================================================
TIME FILTER (BROKER TIME AUTO-DETECT)
================================================================
- Use TimeGMT() to detect broker offset
- Auto-calculate 08:00 UTC based on broker time
- Example: If broker is GMT+3 → trade 11:00–11:05 broker time
================================================================
INPUTS (User Can Change Only These)
================================================================
input double RiskPercent = 0.5; // % risk
input double FixedLotSize = 0.0; // 0 = use % risk, >0 = fixed lots
input int VolumeMultiplier = 2; // Fixed
input int SlippagePips = 3; // Max slippage
input bool UseNewsFilter = true; // Auto-skip news
input string MagicComment = "SBOv1";
================================================================
SESSION LOGIC
================================================================
// Reset at 00:00 UTC
if (TimeHour(TimeGMT()) == 0 && TimeMinute(TimeGMT()) == 0)
{
AsianHigh = -999; AsianLow = 999;
}
// Track Asian range (00:00–07:59 UTC)
if (TimeHour(TimeGMT()) >= 0 && TimeHour(TimeGMT()) < 8)
{
double h = iHigh(_Symbol, PERIOD_H1, 0);
double l = iLow(_Symbol, PERIOD_H1, 0);
if (h > AsianHigh) AsianHigh = h;
if (l < AsianLow) AsianLow = l;
}
// At 08:00 UTC → lock range
if (TimeHour(TimeGMT()) == 8 && TimeMinute(TimeGMT()) == 0)
FinalAsianHigh = AsianHigh; FinalAsianLow = AsianLow;
// Trade window: 08:00–08:05 UTC (broker time adjusted)
datetime brokerTime = TimeCurrent();
int brokerHour = TimeHour(brokerTime);
int brokerMin = TimeMinute(brokerTime);
int utcHour = TimeHour(TimeGMT());
if (utcHour == 8 && brokerMin >= 0 && brokerMin <= 5)
CheckBreakout();
================================================================
VOLUME FILTER
================================================================
double vol = iVolume(_Symbol, PERIOD_M5, 1);
double volAvg = iMA(_Symbol, PERIOD_M5, 20, 0, MODE_SMA, PRICE_VOLUME, 1);
if (vol <= volAvg * VolumeMultiplier) return;
================================================================
ENTRY LOGIC
================================================================
if (iClose(PERIOD_M5, 1) > FinalAsianHigh && iLow(PERIOD_M5, 1) <= FinalAsianHigh)
→ LONG
if (iClose(PERIOD_M5, 1) < FinalAsianLow && iHigh(PERIOD_M5, 1) >= FinalAsianLow)
→ SHORT
================================================================
RISK & POSITION SIZING
================================================================
double slPips = 20;
double lots;
if (FixedLotSize > 0)
lots = FixedLotSize;
else
{
double risk = AccountBalance() * RiskPercent / 100;
double pipValue = MarketInfo(_Symbol, MODE_TICKVALUE);
lots = NormalizeDouble(risk / (slPips * pipValue * 10), 2);
}
lots = MathMax(lots, 0.01);
================================================================
NEWS FILTER (BUILT-IN CALENDAR)
================================================================
- Use Forex Factory RSS or built-in MT5 calendar
- Skip if ANY high-impact event in next 2 hours:
→ NFP, ECB Interest Rate, FOMC, CPI (US/EU)
- Hardcode event names + auto-check
================================================================
TRADE MANAGEMENT
================================================================
- No trailing stop
- No partial close
- Max hold: 8 hours (auto-close at 16:00 UTC)
- If no fill by 08:05 UTC → cancel
- Close at TP or SL only
================================================================
SAFETY FEATURES
================================================================
- No trading on weekends
- No trading if spread > 2.0 pips (iSpread)
- No trading if equity < 50% of start balance
================================================================
DELIVERABLES
================================================================
1. .ex5 file
2. .mq5 source (fully commented)
3. PDF: 1-page user guide
4. CSV: Backtest 2015–2025 (1,026 trades)