Pipsgrowth EX14020 Scalper
MT5 Expert Advisor (Open Source) · XAUUSD · M5, H1
Pipsgrowth.com EX14020 AIXAUUSDScalper — AI-assisted XAUUSD scalper, full 12-layer stack.
Overview
Pipsgrowth EX14020 AIXAUUSDScalper is a single-bar vote-counter for XAUUSD. Each closed M5 bar is fed through four independent filters — a 14-period RSI, a 12/26/9 MACD line-vs-signal comparison, a 50-period EMA, and a 200-period EMA — and each filter that agrees with the bullish direction adds twenty-five points to a buy score. The mirror set of conditions feeds a parallel sell score. When either score reaches the configurable confidence threshold (default InpAIConfidence = 75, i.e. three out of four filters in agreement), the EA fires a market order in that direction.
The decision math is the entire strategy. There is no position-management subroutine. Once a trade is on, nothing else happens to it: no trailing stop, no break-even migration, no partial close, no reverse-signal exit, no time-based exit. The fixed 30-point stop and 50-point target attached at order entry are the only way a position can leave the book, and the only thing the EA does to manage exposure is count open positions through CountTrades() and refuse to open a fourth if three are already live under magic 22214020.
The 200-period EMA is the structural filter that gives the system its directional bias. The buy branch is mathematically reachable only when bid > ema200[0], and the sell branch only when bid < ema200[0]. That single condition forces every entry to be on the same side as the long-term trend, which is the only thing keeping the score from routinely firing both ways on the same bar. In practice the two branches are still evaluated independently — there is no veto that would explicitly cancel a buy when sellScore has also crossed threshold — so during the bar where price crosses the 200-EMA, both branches can resolve true. The OnTick logic does not guard against that; the broker may simply reject the second order, or the spread gate may catch it on the next tick.
The ATR handle (hATR, 14-period) is created in OnInit and released in OnDeinit, but its value is fetched inside OnTick and never used. The indicator exists in the source purely as a placeholder in the '5 indicator handles' stack claimed by the source header; in the live code path the ATR buffer copy is read into a local variable and discarded. The 12-layer architecture claim in the header comment ('REGIME, SIGNAL, ENTRY, CONFIRM, NO-TRADE, CAPITAL CAP, RISK, SIZING, MANAGE, EXIT, SCALING, OnTester') is marketing scaffolding — the runtime implementation is a single-pass score, a single guard pair (spread and trade count), a fixed lot input, fixed stops, and OnInit/OnDeinit housekeeping. There is no OnTester routine, no regime detector, no news filter, no session gate, no day-of-week guard, and no drawdown cap.
The three retry helpers TryClose_EX14020, TryClosePartial_EX14020, and TryModify_EX14020 are declared in the source but never invoked from OnTick. They follow the standard 3-attempt pattern with 200ms close / 100ms modify backoff and treat TRADE_RETCODE_REQUOTE, TRADE_RETCODE_TIMEOUT, TRADE_RETCODE_PRICE_OFF, and TRADE_RETCODE_PRICE_CHANGED as retryable conditions, but the live entry path uses the m_trade object's Buy() and Sell() methods directly, so the only failures a real user will see are raw trade-result codes from a single attempt. OnInit contains an OnInit_20260007_placeholder() stub that exists solely to satisfy the unused-function warning — it returns 0 and is never called.
The RSI thresholds sit at 40 and 60 — closer to the midline than the textbook 30/70 oversold/overbought levels. That choice lets the system act on mild momentum shifts rather than extreme reversals, but it also widens the rate at which the score reaches threshold, which is the entire point of the configurable confidence input: tightening InpAIConfidence up to 100 effectively requires all four filters to agree (a much stricter bar), and dropping it to 50 forces only two filters to align. With the default 75, the system typically needs three of four to agree, which in real XAUUSD M5 data means entries cluster around bars where the 200-EMA bias, the 50-EMA proximity, the MACD direction, and the RSI position all line up within a single five-minute window.
The fixed 30/50 economics in pips (the EA operates in raw _Point units, so the user must calibrate the lot against their broker's point value) make this a high-frequency, low-per-trade-risk design: 0.01 lot on XAUUSD with a 30-point stop is roughly three dollars of risk per trade on a 5-decimal gold quote, and three concurrent positions max out the per-trade risk at around nine dollars per closed-bar burst. The cap on concurrent positions is enforced by CountTrades() on every tick, so the EA will keep stacking entries bar after bar up to the cap, but each new entry is independently scored — there is no averaging, no grid, no martingale, and no recovery multiplier. If all three positions hit their stops, the loss is three times the per-trade stop, full stop.
There is no protection against the classic 200-EMA whip-saw. When gold chops around the daily 200-EMA, the score will keep flipping between buy and sell branches on consecutive bars, generating paired entries in opposite directions that both get stopped. The M5 timeframe and the 3-position cap make this relatively bounded, but it is a structural property of the design: the system follows the trend it sees on each bar, with no memory of what the previous bar said, no concept of trend strength beyond the four indicators, and no mechanism to step aside during a regime where the trend signal is unreliable.
Run it on a low-spread ECN or RAW-spread account where the typical XAUUSD spread is comfortably under the 30-point cap (the InpMaxSpread = 30 default is a generous ceiling for gold — most retail brokers sit at 20-30 points normally and widen to 50+ around news). Test in the strategy tester on real-tick data for at least two years, walk it through a known high-volatility period (March 2020, March 2023 banking stress, August 2024 carry unwind) to verify the score behaves under regime change, and be aware that the fixed lot and fixed stop inputs leave no room for position-sizing adaptation — if the account equity is small, the same 0.01 / 30-point exposure is the only option the EA offers.
Strategy Deep Dive
Pipsgrowth EX14020 reads the four 1-bar values of RSI(14), MACD(12,26,9), EMA(50), and EMA(200) once per closed M5 bar, then walks a fixed vote: each filter that aligns bullish adds 25 to buyScore, each that aligns bearish adds 25 to sellScore. Whichever score first reaches InpAIConfidence (default 75) triggers a single Buy or Sell at the next tick — buy and sell branches are evaluated independently, so on a bar that crosses the 200-EMA both can resolve true. The ATR(14) handle is allocated and pulled but never used; the three TryClose/TryClosePartial/TryModify retry helpers are declared but never called from OnTick. Once a position is open, no management function runs against it — the only path out is the fixed 30-point SL or 50-point TP hitting at the broker, and CountTrades() caps exposure at three concurrent positions under magic 22214020.
Each closed M5 bar is scored on four independent conditions (RSI < 40 vs > 60, MACD line vs signal, bid vs EMA50, bid vs EMA200), each contributing 25 points; when buyScore*25 or sellScore*25 reaches the InpAIConfidence threshold (default 75 = three-of-four agreement), a market order fires in that direction at the next tick.
There is no active exit logic — positions close only when the fixed 30-point stop or 50-point target hits at the broker. No reverse-signal close, no time-based exit, no trailing, no break-even, no partial close. The TryClose_EX14020 / TryClosePartial_EX14020 retry helpers exist in source but are never called from the live OnTick path.
Fixed 30-point stop-loss attached at order entry (ask - 30_Point for buy, bid + 30_Point for sell) and never modified afterward — no trailing, no break-even, no ATR-based adaptation despite hATR being in the handle stack.
Fixed 50-point take-profit attached at order entry (ask + 50_Point for buy, bid - 50_Point for sell), giving a hard-coded 1:1.67 reward/risk ratio. No dynamic TP, no partial close, no break-even migration.
XAUUSD on M5 (and tested through H1), $100 minimum with the 0.01-lot default, HIGH risk classification. Best on a low-spread ECN or RAW account where typical gold spread is comfortably under the 30-point InpMaxSpread ceiling, and most natural around the London–New York overlap where five-minute gold volatility reliably reaches the 30-point stop. The score-threshold design rewards volatile trending days and struggles during 200-EMA chop, so pair it with manual de-risking around high-impact news.
Strategy Logic
Pipsgrowth EX14020 Scalper — Strategy Logic Analysis (from .mq5 source)
Family: Scalper
Magic: 22214020
Version: 2.00
BRIEF:
AI-assisted XAUUSD scalper using a multi-filter signal scoring system combining RSI, MACD, EMA50/200 and ATR. Entry triggers when composite score exceeds configurable confidence
INDICATOR STACK:
- Standard
MT5indicators
KEY FUNCTIONS:
CountTrades()OnInit_20260007_placeholder()TryClose_EX14020()TryClosePartial_EX14020()TryModify_EX14020()
INTERNAL CONSTANTS (0 total):
INPUT PARAMETERS (0 total across 0 groups):
// Pipsgrowth EX14020 Scalper — Execution Flow (from source analysis)
// Family: Scalper
// AI-assisted XAUUSD scalper using a multi-filter signal scoring system combining RSI, MACD, EMA50/200 and ATR. Entry triggers when composite score exceeds configurable confidence
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
#property copyright "Pipsgrowth.com"
#property link "https://pipsgrowth.com"
#property version "2.00"
#property strict
#property description "Pipsgrowth.com EX14020 AIXAUUSDScalper — AI-assisted XAUUSD scalper, full 12-layer stack."
#include <Trade\Trade.mqh>
input group "=== Identity ==="
input int InpMagicNumber = 22214020;
input string InpTradeComment = "Psgrowth.com Expert_14020";
input group "=== Trading ==="
input double InpLotSize = 0.01;
input int InpMaxTrades = 3;
input group "=== Signal ==="
input int InpAIConfidence = 75;
input group "=== Risk ==="
input int InpStopLoss = 30;
input int InpTakeProfit = 50;
input group "=== Filter ==="
input int InpMaxSpread = 30;
CTrade trade;
int hRSI, hMACD, hATR, hEMA50, hEMA200;
datetime lastBar=0;
int OnInit() {
trade.SetExpertMagicNumber(InpMagicNumber);
hRSI = iRSI(_Symbol,PERIOD_CURRENT,14,PRICE_CLOSE);
hMACD = iMACD(_Symbol,PERIOD_CURRENT,12,26,9,PRICE_CLOSE);
hATR = iATR(_Symbol,PERIOD_CURRENT,14);
hEMA50 = iMA(_Symbol,PERIOD_CURRENT,50,0,MODE_EMA,PRICE_CLOSE);
hEMA200= iMA(_Symbol,PERIOD_CURRENT,200,0,MODE_EMA,PRICE_CLOSE);
return INIT_SUCCEEDED;
}
void OnDeinit(const int r) { IndicatorRelease(hRSI);IndicatorRelease(hMACD);IndicatorRelease(hATR);IndicatorRelease(hEMA50);IndicatorRelease(hEMA200); }
void OnTick() {
datetime cb=iTime(_Symbol,PERIOD_CURRENT,0);
if(cb==lastBar) return; lastBar=cb;
if(SymbolInfoInteger(_Symbol,SYMBOL_SPREAD)>InpMaxSpread) return;
if(CountTrades()>=InpMaxTrades) return;
double rsi[1],macd[1],macdSig[1],atr[1],ema50[1],ema200[1];
if(CopyBuffer(hRSI,0,1,1,rsi)<1||CopyBuffer(hMACD,0,1,1,macd)<1||CopyBuffer(hMACD,1,1,1,macdSig)<1||CopyBuffer(hATR,0,1,1,atr)<1||CopyBuffer(hEMA50,0,1,1,ema50)<1||CopyBuffer(hEMA200,0,1,1,ema200)<1) return;
double bid=SymbolInfoDouble(_Symbol,SYMBOL_BID),ask=SymbolInfoDouble(_Symbol,SYMBOL_ASK);
double sl=InpStopLoss*_Point, tp=InpTakeProfit*_Point;
int buyScore=0, sellScore=0;
if(rsi[0]<40) buyScore++; if(rsi[0]>60) sellScore++;
if(macd[0]>macdSig[0]) buyScore++; if(macd[0]<macdSig[0]) sellScore++;
if(bid>ema50[0]) buyScore++; if(bid<ema50[0]) sellScore++;
if(bid>ema200[0]) buyScore++; if(bid<ema200[0]) sellScore++;
if(buyScore*25>=InpAIConfidence) trade.Buy(InpLotSize,_Symbol,ask,ask-sl,ask+tp,InpTradeComment);
if(sellScore*25>=InpAIConfidence) trade.Sell(InpLotSize,_Symbol,bid,bid+sl,bid-tp,InpTradeComment);
}
int CountTrades() { int c=0; for(int i=PositionsTotal()-1;i>=0;i--) if(PositionGetTicket(i)>0&&PositionGetInteger(POSITION_MAGIC)==InpMagicNumber&&PositionGetString(POSITION_SYMBOL)==_Symbol) c++; return c; }
int OnInit_20260007_placeholder() { return 0; } // placeholder to avoid unused warning
//+------------------------------------------------------------------+
bool TryClose_EX14020(ulong ticket)
{
for(int a=0; a<3; a++)
{
if(trade.PositionClose(ticket) &&
(trade.ResultRetcode()==TRADE_RETCODE_DONE || trade.ResultRetcode()==TRADE_RETCODE_DONE_PARTIAL))
Full 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 EX10006 Momentum-Scalper
Pipsgrowth.com EX10006 USDJPY Scalper — USDJPY pullback momentum scalper, full 12-layer stack.
Pipsgrowth EX10004 Momentum-Scalper
Pipsgrowth.com EX10004 TSI XAUUSD 5M — True Strength Index 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.