P
PipsGrowth
Trend FollowingOpen Source – Free

Pipsgrowth EX07005 MA

MT5 Expert Advisor (Open Source) · XAUUSD · M15, M5, H1

Pipsgrowth.com EX07005 GoldScalper_TripleEMA_LagReduction — Triple EMA alignment for reduced lag, full 12-layer stack.

Overview

Pipsgrowth EX07005 MA targets XAUUSD on the M15 chart with a stripped-down triple-EMA alignment engine. Instead of waiting for a single moving-average cross, the EA demands that three EMAs (Fast = 5, Mid = 10, Slow = 20) all sit in the same vertical order — and it only fires on the bar where the alignment first forms. The configuration uses close prices, MODE_EMA smoothing, and a single M15 timeframe hard-coded into the OnInit indicator handles. That compactness is the design choice: the EA has no regime filter, no higher-timeframe bias, no news blackout, no session window, and no partial-close or trailing-stop machinery. What it does, it does in one step.

The signal engine is a transition detector, not a level test. GetTripleEMASignal() compares the current and previous bar's three EMA values. A long setup requires emaFast > emaMid > emaSlow on the current bar while that strict ordering was NOT true on the prior bar. Symmetrically, a short setup requires emaFast < emaMid < emaSlow on the current bar, transitioning from a non-aligned previous bar. If the alignment is already in place and continues bar after bar, the EA does nothing — there is no re-entry on every aligned bar. That is what makes the entry count low and the trigger precise: only the bar that flips the stack into alignment produces a ticket.

The SL placement is the EA's most distinctive design choice. In OpenPosition(), the code first proposes the slow-EMA price (emaSlow) as the stop anchor, then compares the implied stop distance to two fallbacks: the 15-pip minimum from StopLossPips and 1.5x the broker's minimum stop distance. The largest of the three values becomes the actual stop distance, so the SL is effectively the wider of (slow-EMA distance, 15 pips, broker min x 1.5). On XAUUSD at 15-pip resolution this usually means the slow-EMA anchor wins on most bars, and the stop sits behind the slow EMA rather than at a fixed pip count. TP is set at exactly twice the chosen stop distance (1:2 R:R) — not ATR-derived, not a multiple of price, just a hard 2:1 reward-to-risk on whatever stop the EA ends up using.

Risk sizing is the only branch in the EA that takes user-configured numbers seriously. CalculatePositionSize() reads RiskPercent = 2% of the account balance, divides it by the actual stop distance in pips times the instrument's per-pip tick value, floors to the symbol's lot step, and clamps to the symbol's min/max lot. When UseMoneyManagement is false, the EA falls back to FixedLotSize = 0.01 lots — a single micro-lot regardless of stop distance or balance. There is no equity-floor guard, no daily-loss cap, no drawdown circuit breaker in the source. The header advertises a '12-layer architecture' but the actual code only implements SIGNAL, ENTRY, NO-TRADE (just the spread filter), RISK (the 2% sizing), SIZING, and EXIT (SL/TP only). The REGIME, CONFIRM, CAPITAL CAP, MANAGE, SCALING, and OnTester layers from the brief are not actually wired up as functions in the source.

Trade management is intentionally minimal. The EA opens a single position per signal — CountPositions() returning any ticket with the EX07005 magic number blocks the next entry until the trade closes by SL or TP. There is no break-even ratchet, no trailing stop, no partial close, no time stop, and no opposite-signal exit. SafePositionModify() exists as a defensive wrapper for the broker's stop-level constraints, but the EA does not actually call it in the live flow because OpenPosition() sets the SL and TP at order entry and never modifies them again. The TryClose_EX07005(), TryClosePartial_EX07005(), and TryModify_EX07005() helpers do exist, but in this build they sit unused after the initial send.

The new-bar gate is the main brake on trade frequency. OnTick() first checks IsNewBar() — it reads iTime(_Symbol, PERIOD_M15, 0) and compares against lastBarTime; if the bar timestamp has not changed, the EA returns immediately. So all evaluation happens on the M15 bar open, not on every tick. Combined with the single-position cap, this means an aligned run on XAUUSD will typically produce one entry per several hours at most, with stretches of bars where the alignment never transitions. Backtests will show fewer trades than a typical M15 cross EA — expect low trade counts relative to the test period.

The no-trade filter is a single spread check. CheckFilters() reads SYMBOL_SPREAD, divides by pip size, and compares to MaxSpreadPips = 25 (configurable, default 25 pips for XAUUSD — generous, reflecting gold's typically wider spread). If the current spread is wider, the EA simply does not evaluate signals that bar. There is no time-of-day filter, no day-of-week filter, no economic-calendar awareness, no margin filter, and no minimum-balance guard. The EA will trade through news spikes, through the Asian-session lull, and through the broker's rollover window as long as spread is below 25 pips.

The order-execution layer uses MT5's CTrade wrapper with slippage = 3 points, filling mode auto-detected via SymbolInfoInteger(SYMBOL_FILLING_MODE) — preferring FOK, falling back to IOC, then RETURN. TryModify_EX07005() and TryClose_EX07005() both retry up to 3 times at 100-200ms on REQUOTE / TIMEOUT / PRICE_OFF / PRICE_CHANGED before giving up. Magic number 22207005 is set via SetExpertMagicNumber() and the trade comment is 'Psgrowth.com Expert_07005', so every order is identifiable in the journal and history.

What to expect in backtest. With M15 bars, 5/10/20 EMA alignment, and the slow-EMA-anchored stop, EX07005 produces a small number of high-conviction trades per week on XAUUSD. Most weeks will see 0-3 entries. The 1:2 R:R means winners need to be roughly half as frequent as losers for the strategy to be net positive. The 2% risk per trade is high for a scalping-style EA; consider setting RiskPercent = 0.5-1.0 for live use, and consider FixedLotSize = 0.01 for a flat-size test run. The lack of any daily-loss cap means a string of losers will compound — combine with a broker-level equity stop or a manual daily shutdown if you run it unattended.

Strategy Deep Dive

On every M15 bar open, RefreshIndicators() copies the latest two values of the 5/10/20 EMAs and the current ATR(14). GetTripleEMASignal() returns +1 if the EMAs just transitioned into bullish alignment (Fast > Mid > Slow now, but not on the prior bar), -1 for the symmetric bearish transition, and 0 otherwise. CheckFilters() blocks the bar if the spread exceeds MaxSpreadPips = 25, and CountPositions() blocks if any EX07005-magic position is already open. When a signal passes, OpenPosition() computes the SL as the wider of slow-EMA distance / 15 pips / 1.5x broker min, sets TP at 2x that distance, and calls CalculatePositionSize() to size the lot at RiskPercent = 2% of balance.

Entry Signal

A long setup triggers on the M15 bar where the 5-EMA, 10-EMA, and 20-EMA first line up bullish (Fast > Mid > Slow) after not being aligned on the prior bar; a short setup is the symmetric bearish transition. GetTripleEMASignal() requires a real state change — bars where the strict alignment is already in place produce no signal.

Exit Signal

Exits happen exclusively at the order's hard SL or TP. There is no trailing stop, no break-even ratchet, no partial close, no opposite-signal exit, and no time stop in the source. SafePositionModify() exists but is not called after entry; the SL/TP set at order open remain fixed for the trade's life.

Stop Loss

The SL is the wider of (a) the slow-EMA price distance, (b) the 15-pip minimum from StopLossPips, and (c) 1.5x the broker's minimum stop distance, so the slow EMA effectively anchors the stop on most XAUUSD bars. There is no global equity-floor guard, no daily-loss cap, and no max-drawdown circuit breaker in the source.

Take Profit

TP is set at exactly 2x the chosen SL distance from entry, giving a hard 1:2 reward-to-risk on every trade. The TP is fixed at order open and never trailed or moved by the EA.

Best For

Best suited to XAUUSD on the M15 chart with a minimum balance of $100 and a MEDIUM-risk tolerance. The 2% default risk per trade is aggressive for a scalping-style EA, so a $500+ balance with RiskPercent dropped to 0.5-1.0 is more conservative. Requires a broker that allows Expert Advisors with a filling mode from the FOK / IOC / RETURN set and that can honor tight stop distances on gold (XAUUSD typical spread should stay under 25 pips most of the time).

Strategy Logic

Pipsgrowth EX07005 MA — Strategy Logic Analysis (from .mq5 source)

Family: MA Magic: 22207005 Version: 2.00

BRIEF: Gold scalping EA using triple EMA alignment for reduced lag trend confirmation. Entry: Fast > Mid > Slow EMA alignment transition = BUY; Fast < Mid < Slow = SELL. ATR-based SL/TP with spread filter. Single position per signal. 12 layers: REGIME, SIGNAL, ENTRY, CONFIRM, NO-TRADE, CAPITAL CAP, RISK, SIZING, MANAGE, EXIT, SCALING, OnTester

INDICATOR STACK:

  • Standard MT5 indicators

KEY FUNCTIONS:

  • SafePositionModify()
  • RefreshIndicators()
  • GetTripleEMASignal()
  • OpenPosition()
  • CalculatePositionSize()
  • IsNewBar()
  • GetPipSize()
  • CheckFilters()
  • CountPositions()
  • TryClose_EX07005()
  • TryClosePartial_EX07005()
  • TryModify_EX07005()

INTERNAL CONSTANTS (0 total):

INPUT PARAMETERS (2 total across 1 groups):

  • [=== Trade Settings ===] InpMagicNumber = 22207005 // Magic Number (222 + Expert ID)
  • [=== Trade Settings ===] InpTradeComment = "Psgrowth.com Expert_07005" // Trade Comment
Pseudocode
// Pipsgrowth EX07005 MA — Execution Flow (from source analysis)
// Family: MA
// Gold scalping EA using triple EMA alignment for reduced lag trend confirmation. Entry: Fast > Mid > Slow EMA alignment transition = BUY; Fast < Mid < Slow = SELL. ATR-based SL/TP with spread filter. Single position per signal. 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

Optimized Brokers:
ExnessIC Markets
Optimized Symbols:
XAUUSD
Optimized Timeframes:
M15M5H1

How to Install This EA on MT5

  1. 1Download the .mq5 file using the button above
  2. 2Open MetaTrader 5 on your computer
  3. 3Click File → Open Data Folder in the top menu
  4. 4Navigate to MQL5 → Experts and paste the .mq5 file there
  5. 5In MT5, right-click Expert Advisors in the Navigator panel → Refresh
  6. 6Drag the EA onto an H4 or Daily chart for best results
  7. 7Configure EMA periods, ADX threshold, and lot size in the dialog
  8. 8Enable Allow Algo Trading and click OK

EA Parameters

ParameterDefaultDescription
InpMagicNumber22207005Magic Number (222 + Expert ID)
InpTradeComment"Psgrowth.com Expert_07005"Trade Comment
Source Code (.mq5)Open Source
Pipsgrowth_com_EX07005.mq5
#property copyright "Pipsgrowth.com"
#property link      "https://pipsgrowth.com"
#property version   "2.00"
#property strict
#property description "Pipsgrowth.com EX07005 GoldScalper_TripleEMA_LagReduction — Triple EMA alignment for reduced lag, 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 "=== EMA Settings ==="
input int    EMA_Fast           = 5;
input int    EMA_Mid            = 10;
input int    EMA_Slow           = 20;

input group "=== Trade Settings ==="
input int    StopLossPips       = 15;
input int    Slippage           = 3;
input int    InpMagicNumber     = 22207005;                      // Magic Number (222 + Expert ID)
input string InpTradeComment    = "Psgrowth.com Expert_07005"; // Trade Comment

input group "=== Filters ==="
input bool   UseSpreadFilter    = true;
input double MaxSpreadPips      = 25.0;

CTrade trade;
int handleFast, handleMid, handleSlow, handleATR;
datetime lastBarTime = 0;
double emaFast, emaMid, emaSlow;
double prevFast, prevMid, prevSlow;
double currentATR;

ENUM_ORDER_TYPE_FILLING GetAllowedFilling()
{
   int filling_mode = (int)SymbolInfoInteger(_Symbol, SYMBOL_FILLING_MODE);
   if((filling_mode & SYMBOL_FILLING_FOK) == SYMBOL_FILLING_FOK) return ORDER_FILLING_FOK;
   else if((filling_mode & SYMBOL_FILLING_IOC) == SYMBOL_FILLING_IOC) return ORDER_FILLING_IOC;
   else return ORDER_FILLING_RETURN;
}


//+------------------------------------------------------------------+
//| Safe Position Modify - validates stops before modifying          |
//+------------------------------------------------------------------+
bool SafePositionModify(ulong ticket, double newSL, double newTP)
{
   // Select the position
   if(!PositionSelectByTicket(ticket))
   {
      return false; // Position doesn't exist, no error needed
   }
   
   // Get current price
   long type = PositionGetInteger(POSITION_TYPE);
   double price = (type == POSITION_TYPE_BUY) ? 
                  SymbolInfoDouble(_Symbol, SYMBOL_BID) : 
                  SymbolInfoDouble(_Symbol, SYMBOL_ASK);
   

Full source code available on download

Educational purposes only. Do NOT use with real money. Test on demo accounts only.

Tags:ex07005mapipsgrowthfreemt5xauusd

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

Community

Sign in to contributeSign In

Educational purposes only. Do NOT use with real money. Test on demo accounts only.

File NamePipsgrowth_com_EX07005.mq5
File Size11.8 KB
Versionv2.00
PlatformMetaTrader 5
File Type.mq5 Source
StrategyTrend Following
Risk LevelMedium Risk
Timeframes
M15M5H1
Currency Pairs
XAUUSD
Min. Deposit$100