Pipsgrowth EX10013 Momentum-Scalper
MT5 Expert Advisor (Open Source) · XAUUSD · M5, H1
Pipsgrowth.com EX10013 GoldScalper StochMomentum — Stochastic momentum fast oscillator scalper, full 12-layer stack.
Overview
EX10013 trades a single idea and trades it well: when the fast Stochastic on the M15 timeframe crosses out of an oversold or overbought zone, the EA opens one position and holds it until either the target fills or the next reversal prints. The execution time is also M5 — the EA reads its signal from M15 candles, then runs trade-management on every M5 bar. That split timeframe is the architectural signature: a slower indicator period for signal clarity, a faster bar period for tight risk control. There is no EMA cross, no RSI confirmation, no ADX regime filter, and no higher-timeframe trend gate. The logic is intentionally narrow so that every component is auditable in the source.
Signal formation is direct. On every new M15 bar, the EA copies the latest two K values and two D values from the Stochastic (period K = 5, D = 3, slowing = 3, MODE_SMA, STO_LOWHIGH). A long entry triggers when the previous K was at or below the previous D and the current K has crossed above D, provided the current K is still under 30 (the oversold level of 20 plus a 10-point buffer that lets the cross happen just as momentum is recovering rather than deep in the floor). A short entry is the mirror: previous K at or above D, current K now below D, current K still above 70 (the overbought level of 80 minus a 10-point buffer). Both signals must use the previous and current bar — the EA deliberately uses a two-bar lookback on the indicator to avoid acting on a still-forming candle. The OnTick handler returns immediately unless IsNewBar() confirms a fresh M15 close, which is what enforces the no-repaint rule.
The position-management layer is equally compact. ManageOpenPositions runs on every tick and looks for the opposite momentum signature: a long position is closed when the current Stochastic K is over 80 and starts turning down (K above D and crossing down); a short position is closed when K is under 20 and starts turning up. This is a fast counter-signal exit. There is no break-even step, no partial close, no time-based failsafe, no trail. A position either fills its take-profit, hits its stop-loss, or exits on the first qualifying counter-signal — whichever comes first. The single-position rule is enforced by CountPositions() >= 1: if there is already one open position for this magic number, no new entry fires.
Stop-loss is a hybrid. The EA computes slDist = max(ATR(14) × 1.5, 15 pips × pipSize, broker minimum distance × 1.5). On gold, ATR(14) on M15 is typically 80–150 points, so the ATR floor usually wins once the session gets going. The 15-pip floor is the safeguard for quiet Asian hours when ATR has compressed. The take-profit is a fixed 1.5 × slDist, giving a 1:1.5 R-multiple on the target side — a slightly sub-1R setup that the high hit-rate of mean-reversion crosses is supposed to compensate for. Position sizing is risk-percent based by default (2% of account balance per trade, with a 0.01 fixed-lot fallback) and is hard-capped at InpMaxLot = 5.0 lots per trade.
The safety stack mirrors the rest of the family. IsSafeToTrade_EX10013 runs eight gates before the indicator copy even starts. The capital allocation cap (InpCapAmount, zero disables) prevents the EA from ever treating more than the configured cap as tradeable equity, with a hard floor of $50 (InpCapFloor) that blocks entries when the account falls below. A 95% initial-balance floor shuts the EA down if the account has lost more than 5% from where it started, regardless of recent wins. A 3% daily realized loss limit and a 6% weekly realized loss limit (2× daily) are read straight from the deal stream by OnTradeTransaction, which walks a 90-day history window for DEAL_ENTRY_OUT deals matching this magic number. Three consecutive losses on the same magic number start a 30-minute cooldown. The trade counter caps entries at 50 per day.
The session filter is set in GMT, not server time. DetectGMTOffset_EX10013 walks the H1 bars looking for a 3+ hour weekend gap, then infers the broker's UTC offset from the bar timestamp (defaulting to InpServerGMTOffset if you set it manually). InActiveSession then asks: is the current GMT time in London (07:00–16:00), New York (12:00–21:00), or (with InpAvoidAsia on) nowhere else? Asian hours (00:00–07:00 GMT) are blocked by default because the spread and the chop on gold are unfriendly. Friday after 22:00 server time and the entire Saturday are blocked outright by IsMarketOpen. An optional news filter (InpNewsFilter) closes a 15-minute window around the London and New York session opens.
The retry logic is conservative. TryClose_EX10013 and TryModify_EX10013 each retry up to 3 times on the standard transient codes (REQUOTE, TIMEOUT, PRICE_OFF, PRICE_CHANGED) with 200ms and 100ms sleeps respectively. OpenPosition retries 3 times with a 500ms sleep and incrementally widens the slippage from the base Slippage=3 by 5 points per attempt before giving up. GetAllowedFilling() auto-picks the filling policy from the broker's SYMBOL_FILLING_MODE flag, preferring FOK, then IOC, then RETURN — so the EA works on netting, hedging, and exchange-style accounts without code changes. OnTester scores the backtest as (netProfit × profitFactor) / (1 + maxDD%) with a 30-trade minimum, which favors tight-drawdown curves over raw net profit.
EX10013 is the lean option in the EX10 family. Where EX10007 layers EMA, RSI, ADX, Bollinger Bands, and an M15 HTF confirm into a six-clause trend pullback, and where EX10008 dispatches five separate signal paths by market regime, EX10013 keeps just one indicator and one entry shape. The trade-off is precision over breadth: when gold runs in a clean mean-reversion pattern inside London or NY, the Stochastic cross fires close to the swing and the 1.5R target captures a meaningful slice. When gold trends hard, the same cross fires repeatedly against the move and the SL takes the loss. The EA has no regime detection to tell those two situations apart, so the backtest will show a profit factor that is sensitive to the test period's character — a quiet 2023 may look very different from a news-driven 2024.
Strategy Deep Dive
EX10013 sits on top of two M15 indicator handles — a Stochastic (K=5, D=3, slowing=3, MODE_SMA, STO_LOWHIGH) and a 14-period ATR — and the OnTick handler routes everything else around them. RefreshIndicators copies the latest two K and two D values plus the current ATR on every new M15 bar; GetStochSignal returns +1 for a K-up-cross of D under 30, -1 for a K-down-cross of D above 70, and 0 otherwise. The IsNewBar gate is what gives the EA its no-repaint guarantee — the EA refuses to act until a closed M15 bar is available. Position management runs on the M5 tick: ManageOpenPositions walks PositionsTotal looking for the counter-signal exit, and OpenPosition sizes the trade by calling CalculatePositionSize with the ATR-based slDist in pips. GetAllowedFilling auto-picks FOK > IOC > RETURN from the broker's SYMBOL_FILLING_MODE flag. The safety stack — IsSafeToTrade_EX10013 — runs eight gates before signal evaluation: cap reached, equity floor 95%, daily loss 3%, weekly loss 6%, consecutive-loss cooldown, 50-trade daily cap, market open, and session filter. OnTradeTransaction walks the 90-day deal history to update g_realizedToday, g_consecLosses, and g_tradesToday from real DEAL_ENTRY_OUT records, not from internal bookkeeping. OnTester scores the backtest as (net × PF) / (1 + DD%) with a 30-trade minimum.
EX10013 reads the Stochastic (K=5, D=3, slowing=3, MODE_SMA, STO_LOWHIGH) on the M15 timeframe, then enters on the next M5 tick after a new M15 bar closes. A long is triggered when the previous bar's K was at or below D, the current bar's K has crossed above D, and the current K is still under 30 (oversold 20 plus a 10-point buffer). A short is the mirror with K crossing below D from above 70 (overbought 80 minus the 10-point buffer). Only one position per magic number can be open at a time.
ManageOpenPositions scans every tick for a counter-signal: a long is closed when K pushes above 80 and rolls over below D, and a short is closed when K drops below 20 and curls back above D. The position also exits on its take-profit or stop-loss fill, whichever comes first. There is no time-based exit, partial close, break-even step, or trailing logic in this EA — the counter-signal is the only discretionary exit.
Stop-loss is hybrid: slDist = max(ATR(14) × 1.5, 15 pips, broker minimum distance × 1.5), all converted to price units. The ATR floor dominates during active sessions (typically 80–150 points on M15 gold), the 15-pip floor protects compressed-volatility windows like the Asian open, and the broker minimum prevents invalid stops. SL is fixed at order entry and is not trailed.
Take-profit is fixed at 1.5 × slDist for a 1:1.5 risk-to-reward on the target side (a sub-1R setup that depends on the high hit-rate of mean-reversion crosses to compensate). TP is set on the order and is never trailed or partially closed.
XAUUSD on M5 execution with a broker whose spread stays well under 25 pips in London and New York, since the Stochastic mean-reversion edge depends on entering close to the swing. Minimum recommended balance: $100, but $500+ gives the 2% risk-per-trade rule room to size meaningful lots without floor effects. Run on an ECN or RAW-spread account, MT5 build 3800+, with server time anchored to GMT (auto-detect is on by default; set InpServerGMTOffset manually if your broker's weekend gap is ambiguous). Avoid the EA on the Asian session (00:00–07:00 GMT) — InpAvoidAsia is on by default for that reason. Tighten the Stochastic OB/OS levels or disable InpAvoidAsia only if you have a specific thesis about an Asian-session range trade.
Strategy Logic
Pipsgrowth EX10013 Momentum-Scalper — Strategy Logic Analysis (from .mq5 source)
Family: Momentum-Scalper
Magic: 22210013
Version: 2.00
BRIEF:
Gold scalping EA using Stochastic Momentum Fast Oscillator crossovers with momentum confirmation. Buys on stochastic cross up from oversold, sells on cross down from overbought. Includes spread filter, ATR-based SL/TP, and money management. 12 layers: REGIME, SIGNAL, ENTRY, CONFIRM, NO-TRADE, CAPITAL CAP, RISK, SIZING, MANAGE, EXIT, SCALING, OnTester
INDICATOR STACK:
- Standard
MT5indicators
KEY FUNCTIONS:
SafePositionModify()OnTradeTransaction()RefreshIndicators()GetStochSignal()OpenPosition()ManageOpenPositions()CalculatePositionSize()IsNewBar()GetPipSize()CheckFilters()CountPositions()EffectiveCapital_EX10013()- ...and 9 more
INTERNAL CONSTANTS (0 total):
INPUT PARAMETERS (18 total across 3 groups):
- [=== Trade Settings ===]
InpMagicNumber=22210013// Magic Number - [=== Trade Settings ===]
InpTradeComment= "Psgrowth.com Expert_10013" // TradeComment - [=== Hardening: Risk Management ===]
InpDailyLossLimitPct=3.0// Daily loss limit (% of effective capital) - [=== Hardening: Risk Management ===]
InpMaxLot=5.0// Hard lot cap per trade - [=== Hardening:
GMTSessions ===]InpServerGMTOffset= 0 // ServerGMToffset hours (0=auto-detect) - [=== Hardening:
GMTSessions ===]InpLondonStartHour= 7 // London session start (GMT) - [=== Hardening:
GMTSessions ===]InpLondonEndHour= 16 // London session end (GMT) - [=== Hardening:
GMTSessions ===]InpNYStartHour= 12 // New York session start (GMT) - [=== Hardening:
GMTSessions ===]InpNYEndHour= 21 // New York session end (GMT) - [=== Hardening:
GMTSessions ===]InpAvoidAsia=true// Avoid Asian session - [=== Hardening:
GMTSessions ===]InpAsiaStartHour= 0 // Asian session start (GMT) - [=== Hardening:
GMTSessions ===]InpAsiaEndHour= 7 // Asian session end (GMT) - [=== Hardening:
GMTSessions ===]InpNewsFilter=false// Avoid trading near news session opens - [=== Hardening:
GMTSessions ===]InpNewsFilterMinutes= 15 // Minutes to avoid around news - [=== Hardening:
GMTSessions ===]InpMaxTradesPerDay= 50 // Maximum trades per day - [=== Hardening:
GMTSessions ===]InpMinEquityPercent=95.0// Stop trading if equity < this % of initial balance - [=== Hardening:
GMTSessions ===]InpCooldownMinutes= 30 // Cooldown minutes after consec losses - [=== Hardening:
GMTSessions ===]InpMaxConsecLosses= 3 // Max consecutive losses before cooldown
// Pipsgrowth EX10013 Momentum-Scalper — Execution Flow (from source analysis)
// Family: Momentum-Scalper
// Gold scalping EA using Stochastic Momentum Fast Oscillator crossovers with momentum confirmation. Buys on stochastic cross up from oversold, sells on cross down from overbought. Includes spread filter, ATR-based SL/TP, and money management. 12 layers: REGIME, SIGNAL, ENTRY, CONFIRM, NO-TRADE, CAPITAL CAP, RISK, SIZING, MANAGE, EXIT, SCALING, OnTester
ON_INIT:
Create indicator handles: standard set
Initialize state variables
Detect broker GMT offset
ON_TICK:
1. Refresh indicator buffers (closed-bar shift=1)
2. Manage existing positions:
- Break-even check
- ATR trailing stop
- Profit lock ratchet
- Time-based exit
- Opposite-signal exit
3. If new bar:
a. ClassifyRegime() — ADX/ATR/BB regime detection
b. NoTradeGate() checks:
- Market open + session filter
- Spread limit
- Cooldown after loss
- Consecutive loss limit
- Kill switch
- Max drawdown
- Max concurrent positions
- Daily/weekly loss limits
c. GenerateSignal() — strategy-specific entry logic
d. CheckConfirm() — HTF alignment + R:R + ADX minimum
e. Calculate position size from risk %
f. Execute with retry logic
g. Mark bar to prevent duplicates
ON_TESTER:
Custom fitness = weighted(RecoveryFactor, ROI, ProfitFactor, TradeCount, Sharpe, Drawdown)Optimization Profile
How to Install This EA on MT5
- 1Download the .mq5 file using the button above
- 2Open MetaTrader 5 on your computer
- 3Click File → Open Data Folder in the top menu
- 4Navigate to MQL5 → Experts and paste the .mq5 file there
- 5In MT5, right-click Expert Advisors in the Navigator panel → Refresh
- 6Drag the EA from the Navigator onto any chart (M1 or M5 recommended)
- 7In the EA dialog, enable Allow Algo Trading and set your lot size
- 8Click OK — the EA will begin trading automatically
EA Parameters
| Parameter | Default | Description |
|---|---|---|
| InpMagicNumber | 22210013 | Magic Number |
| InpTradeComment | "Psgrowth.com Expert_10013" | Trade Comment |
| InpDailyLossLimitPct | 3.0 | Daily loss limit (% of effective capital) |
| InpMaxLot | 5.0 | Hard lot cap per trade |
| InpServerGMTOffset | 0 | Server GMT offset hours (0=auto-detect) |
| InpLondonStartHour | 7 | London session start (GMT) |
| InpLondonEndHour | 16 | London session end (GMT) |
| InpNYStartHour | 12 | New York session start (GMT) |
| InpNYEndHour | 21 | New York session end (GMT) |
| InpAvoidAsia | true | Avoid Asian session |
| InpAsiaStartHour | 0 | Asian session start (GMT) |
| InpAsiaEndHour | 7 | Asian session end (GMT) |
| InpNewsFilter | false | Avoid trading near news session opens |
| InpNewsFilterMinutes | 15 | Minutes to avoid around news |
| InpMaxTradesPerDay | 50 | Maximum trades per day |
| InpMinEquityPercent | 95.0 | Stop trading if equity < this % of initial balance |
| InpCooldownMinutes | 30 | Cooldown minutes after consec losses |
| InpMaxConsecLosses | 3 | Max consecutive losses before cooldown |
#property copyright "Pipsgrowth.com"
#property link "https://pipsgrowth.com"
#property version "2.00"
#property strict
#property description "Pipsgrowth.com EX10013 GoldScalper StochMomentum — Stochastic momentum fast oscillator scalper, full 12-layer stack."
#include <Trade\Trade.mqh>
input group "=== Risk Management ==="
input bool UseMoneyManagement = true;
input double RiskPercent = 2.0;
input double FixedLotSize = 0.01;
input group "=== Stochastic Settings ==="
input int Stoch_K = 5;
input int Stoch_D = 3;
input int Stoch_Slowing = 3;
input int OverboughtLevel = 80;
input int OversoldLevel = 20;
input group "=== Trade Settings ==="
input int StopLossPips = 15;
input int Slippage = 3;
input int InpMagicNumber = 22210013; // Magic Number
input string InpTradeComment = "Psgrowth.com Expert_10013"; // Trade Comment
input group "=== Filters ==="
input bool UseSpreadFilter = true;
input double MaxSpreadPips = 25.0;
input group "=== Hardening: Risk Management ==="
input double InpDailyLossLimitPct = 3.0; // Daily loss limit (% of effective capital)
input double InpMaxLot = 5.0; // Hard lot cap per trade
input group "=== Capital Allocation Cap ==="
// InpCapEnabled removed — use InpCapAmount=0 to disable
input double InpCapAmount = 0.0;
input double InpCapFloor = 50.0;
input group "=== Hardening: GMT Sessions ==="
input int InpServerGMTOffset = 0; // Server GMT offset hours (0=auto-detect)
input int InpLondonStartHour = 7; // London session start (GMT)
input int InpLondonEndHour = 16; // London session end (GMT)
input int InpNYStartHour = 12; // New York session start (GMT)
input int InpNYEndHour = 21; // New York session end (GMT)
input bool InpAvoidAsia = true; // Avoid Asian session
input int InpAsiaStartHour = 0; // Asian session start (GMT)
input int InpAsiaEndHour = 7; // Asian session end (GMT)
input bool InpNewsFilter = false; // Avoid trading near news session opens
input int InpNewsFilterMinutes = 15; // Minutes to avoid around news
input int InpMaxTradesPerDay = 50; // Maximum trades per day
input double InpMinEquityPercent = 95.0; // Stop trading if equity < this % of initial balance
input int InpCooldownMinutes = 30; // Cooldown minutes after consec losses
input int InpMaxConsecLosses = 3; // Max consecutive losses before cooldown
CTrade trade;
int handleStoch, handleATR;
datetime lastBarTime = 0;
double stochK, stochD, prevK, prevD, currentATR;
//--- Hardening globalsFull source code available on download
Educational purposes only. Do NOT use with real money. Test on demo accounts only.
Clear Warning: Educational Purposes Only
Clear Warning: This Expert Advisor is for educational and testing purposes only. Do NOT use it with real money. Test only on demo accounts. Trading with real money involves substantial risk of capital loss. This does not constitute investment advice.
Recommended Brokers for This EA
These EAs run on MT5 — use a regulated broker with fast execution and tight spreads
Markets.com
Exness
IC Markets
Similar Expert Advisors
View All Expert AdvisorsMore Scalping strategy EAs from our library
Pipsgrowth EX14020 Scalper
Pipsgrowth.com EX14020 AIXAUUSDScalper — AI-assisted XAUUSD scalper, full 12-layer stack.
Pipsgrowth EX10006 Momentum-Scalper
Pipsgrowth.com EX10006 USDJPY Scalper — USDJPY pullback momentum scalper, full 12-layer stack.
Pipsgrowth EX14021 Scalper
Pipsgrowth.com EX14021 EURUSDScalper — BB + MACD divergence scalper, full 12-layer stack.
Community
Educational purposes only. Do NOT use with real money. Test on demo accounts only.