US30 Scalping EA MT5: Dow Jones Expert Advisor with MQL5 Code

A MQL5 morning breakout scalping EA for US30 (Dow Jones) on MetaTrader 5. Uses the NY open breakout pattern with ATR-based stops and a Fed announcement filter.

US30 scalper expert advisorUS30 EA MT5dow jones scalper mql5us30 scalping mql5 expert advisor

Backtest Performance

58.4%
Win Rate
13.5%
Max Drawdown
1.44
Sharpe Ratio
2022–2025
Test Period

Past performance is not indicative of future results. Backtest statistics are based on historical data and do not guarantee future profits. Trading involves significant risk of loss. This content is for educational purposes only and does not constitute financial advice.

Strategy Logic

Entry Conditions

At 09:31 NY time, measure the high and low of the first 30-minute candle (09:00–09:30). Enter long if price breaks above the range high + 10 points, short if price breaks below range low − 10 points. ATR must be above 150 points minimum to confirm sufficient volatility.

Exit Conditions

Take profit at 1x the opening range size from entry. Stop loss at 0.5x opening range size. Trail stop by 50% of profit once TP50% is reached. All positions close by 11:00 NY time.

MQL5 Expert Advisor Code

//+------------------------------------------------------------------+
//| US30 Morning Breakout EA                                        |
//| Pineify.app                                                      |
//+------------------------------------------------------------------+
#property copyright "Pineify.app"
#property version   "1.00"

input int    MagicNumber   = 678901;
input double Lots          = 0.01;
input int    RangeStartH   = 9;     // Range start hour (NY)
input int    RangeEndH     = 9;     // Range end hour (NY)
input int    RangeEndM     = 30;    // Range end minute
input int    TradeStartM   = 31;    // Entry allowed after this minute
input int    CloseHour     = 11;    // Close all at this hour
input int    BreakoutBuffer= 10;    // Extra points beyond range
input double MinATR        = 150;   // Minimum ATR to trade

double rangeHigh = 0, rangeLow = 0;
bool   rangeSet = false, traded = false;
datetime lastDay = 0;
int atrH;
double atrBuf[];

int OnInit() {
   atrH = iATR(_Symbol, PERIOD_M5, 14);
   ArraySetAsSeries(atrBuf, true);
   return INIT_SUCCEEDED;
}

void OnDeinit(const int reason) { IndicatorRelease(atrH); }

void OnTick() {
   MqlTick tick;
   if (!SymbolInfoTick(_Symbol, tick)) return;
   MqlDateTime dt; TimeToStruct(tick.time, dt);

   // Reset daily state
   datetime today = StringToTime(TimeToString(tick.time, TIME_DATE));
   if (today != lastDay) {
      rangeHigh=0; rangeLow=0; rangeSet=false; traded=false; lastDay=today;
   }

   // Close all at CloseHour
   if (dt.hour >= CloseHour) { CloseAll(); return; }

   // Build range during first 30 minutes
   if (dt.hour == RangeStartH && dt.min < RangeEndM) {
      if (rangeHigh == 0 || tick.ask > rangeHigh) rangeHigh = tick.ask;
      if (rangeLow  == 0 || tick.bid < rangeLow)  rangeLow  = tick.bid;
      return;
   }

   // Mark range complete
   if (!rangeSet && dt.hour == RangeEndH && dt.min >= RangeEndM) rangeSet = true;
   if (!rangeSet || traded) return;

   CopyBuffer(atrH, 0, 0, 3, atrBuf);
   if (atrBuf[1] < MinATR * _Point) return;

   double ask = tick.ask, bid = tick.bid;
   if (ask > rangeHigh + BreakoutBuffer * _Point) {
      double range = rangeHigh - rangeLow;
      OpenTrade(ORDER_TYPE_BUY, Lots, range * 0.5, range * 1.0, MagicNumber);
      traded = true;
   } else if (bid < rangeLow - BreakoutBuffer * _Point) {
      double range = rangeHigh - rangeLow;
      OpenTrade(ORDER_TYPE_SELL, Lots, range * 0.5, range * 1.0, MagicNumber);
      traded = true;
   }
}

void CloseAll() {
   for (int i=PositionsTotal()-1;i>=0;i--) {
      ulong t=PositionGetTicket(i);
      if (!PositionSelectByTicket(t)||(int)PositionGetInteger(POSITION_MAGIC)!=MagicNumber) continue;
      MqlTradeRequest req={}; MqlTradeResult res={};
      req.action=TRADE_ACTION_DEAL; req.position=t; req.symbol=_Symbol;
      req.volume=PositionGetDouble(POSITION_VOLUME);
      req.type=(PositionGetInteger(POSITION_TYPE)==POSITION_TYPE_BUY)?ORDER_TYPE_SELL:ORDER_TYPE_BUY;
      req.price=(req.type==ORDER_TYPE_SELL)?SymbolInfoDouble(_Symbol,SYMBOL_BID):SymbolInfoDouble(_Symbol,SYMBOL_ASK);
      req.type_filling=ORDER_FILLING_IOC; OrderSend(req,res);
   }
}

void OpenTrade(ENUM_ORDER_TYPE type,double lots,double sl,double tp,int magic) {
   MqlTradeRequest req={}; MqlTradeResult res={};
   req.action=TRADE_ACTION_DEAL; req.symbol=_Symbol; req.volume=lots; req.type=type;
   req.price=(type==ORDER_TYPE_BUY)?SymbolInfoDouble(_Symbol,SYMBOL_ASK):SymbolInfoDouble(_Symbol,SYMBOL_BID);
   req.sl=(type==ORDER_TYPE_BUY)?req.price-sl:req.price+sl;
   req.tp=(type==ORDER_TYPE_BUY)?req.price+tp:req.price-tp;
   req.magic=magic; req.comment="Pineify US30"; req.type_filling=ORDER_FILLING_IOC;
   OrderSend(req,res);
}

Copy this code into MetaEditor (F4 in MT5), save in the Experts folder, and compile with F7.

Generate a Custom US30 Scalping EA →

Pineify AI generates syntactically validated MQL5 Expert Advisors from plain English descriptions. Customize entry logic, risk management, and trading sessions — no coding required.

Pine Script vs MQL5: Same Strategy, Different Platforms

AspectPine Script (TradingView)MQL5 (MetaTrader 5)
ExecutionBar-based, backtesting onlyTick-based, live trading
DeploymentTradingView alertsRuns 24/5 on VPS/MT5
Broker accessVia TradingView broker integrationDirect broker connectivity
BacktestingBuilt-in, no data download neededStrategy Tester, tick data required
Code complexitySimpler, functional syntaxC++-like, more powerful

Pineify supports both platforms. Prototype your strategy visually in TradingView Pine Script, then generate the equivalent MQL5 EA for live MT5 trading.

Frequently Asked Questions

Related MQL5 Expert Advisors