Pipsgrowth EX07012 MA
MT5 Expert Advisor (Open Source) · XAUUSD · M5, H1
Pipsgrowth.com EX07012 EMA_Crossover_EA — fast/slow EMA crossover with SL/TP, full 12-layer stack.
Overview
EX07012 is the leanest member of the PipsGrowth MA Cross family. The whole trading decision is built around two exponential moving averages and the moment those two lines cross on the live chart. There is no regime filter, no higher-timeframe confirmation, no news blackout, no risk-percent position sizing, and no trailing stop in this EA. It takes its cues directly from the live price action, opens a position when the fast EMA moves across the slow EMA, and exits either at a hard stop or take-profit on the server, or when the averages cross the other way and the on-chart management routine force-closes the position.
The default pair of periods is 12 and 26, the same span used by the classic MACD indicator. The applied price defaults to 1, which the MapAppliedPriceInt helper function resolves to PRICE_CLOSE. The same helper function appears three times in the file (a duplicated block, harmless because the bodies are identical and the last definition wins), and the user can also select open, high, low, median, typical, or weighted via the InpAppliedPrice input. The MA method is MODE_EMA by default and is user-selectable, so the same EA can be flipped into a slow SMA, SMMA, or LWMA crossover just by changing one input. The g_InpAppliedPrice global captures the resolved enum once at OnInit so the indicator handles are built with the right price source.
The crossover detection is performed by DetectSignal(). It reads the current bar's fast and slow EMA at shift 0 and the same two values at shift 1. A bullish cross is recorded when the previous bar's fast value was less-than-or-equal to the slow value and the current bar's fast value is now above the slow value. A bearish cross is the mirror: the previous bar's fast was greater-than-or-equal to the slow and the current bar's fast is now below the slow. The signal is tagged with the iTime of the forming bar, and g_lastSignalTime deduplicates entries so the EA does not fire a second order on every tick of the same cross candle. That guard is the only tick-level safety the EA has against over-trading.
When a fresh cross is registered and is a buy, OpenOrder(ORDER_TYPE_BUY) is called. The function asks the broker for the current ASK, subtracts InpStopLoss points (default 50) for the stop, adds InpTakeProfit points (default 100) for the target, and sends a trade.Buy() with the configured InpLotSize (0.1 by default), the EA's magic number 22207012, and the comment string "Psgrowth.com Expert_07012". The sell path mirrors that exactly against the BID. The hardcoded 1:2 stop-to-target geometry is a deliberate part of the design: the EA only ever opens with a 50-point risk and a 100-point reward, and changing one input requires a corresponding change to the other to keep the symmetry.
Once a position is open, the EA does not touch its stop or take-profit. There is no breakeven ratchet, no partial close, no trailing logic, and no time stop. The only exit intervention happens inside ManagePositions(). On every tick, it checks whether the current fast/slow EMA state is bullish or bearish. If it is bullish, it sweeps through PositionsTotal() from the end to the start and closes any of the EA's own sells (magic 22207012, same symbol). If it is bearish, it closes any of the EA's own buys. This is the reverse-signal exit: a position is held until the average configuration itself turns against it. Because the close is driven by the same live bar that the entry was, a position can be exited on the same tick the averages flip.
Order closing and any future modifications go through three retry wrappers: TryClose_EX07012, TryClosePartial_EX07012, and TryModify_EX07012. Each loops up to three times, sleeping 200ms on a REQUOTE, PRICE_OFF, PRICE_CHANGED, or TIMEOUT before retrying, and giving up cleanly on any other return code. The wrappers use a single shared CTrade g_trade_wrappers_EX07012 instance, while OpenOrder() and ClosePositionsByType() construct a fresh CTrade object per call. That is an inconsistency in the source: the shared instance is correct for the retry loops but is not used everywhere, and the local objects inside the close-sweep function are also fine for one-shot sends.
The EA has a slot for an InpEAOptimized boolean input. The header comment makes the intent explicit: it is "Kept for compatibility" only, and the value has no effect on the live trading logic. The slot exists because earlier MQL Expert Advisor templates used the flag to switch between fixed-lot and percent-risk sizing; EX07012 ships the fixed-lot path and discards the rest. IndicatorRelease is called on both g_fastHandle and g_slowHandle in OnDeinit so the EA cleans up after itself cleanly when removed from the chart.
The risk profile is what the inputs say it is. There is no InpRiskPercent, no daily-loss guard, no weekly guard, no equity-floor check, no drawdown cap, and no kill switch. Whoever sets up the chart is responsible for the lot size, the broker's maximum position size, and the account's free margin. The recommended minimum deposit of $100 is sized to the default 0.1 lot on a major pair or on XAUUSD with a 50-point stop; the EA does not enforce that. There is no OnTester() fitness function in the source, so the optimization target in the MT5 Strategy Tester is whatever the user sets on the Inputs tab.
What EX07012 is best suited for is short-horizon mean-reversion and momentum confirmation in trending pairs, with the trader accepting that any filter layer (session, spread, news, equity guard) must be added externally, or by running the EA on a single well-chosen symbol and timeframe. The default M5 is the suggested horizon in the header, and the EA runs unchanged on M5 through H1. For traders who want a transparent crossover signal with no hidden filters and a 1:2 SL:TP geometry baked in, this is the most direct option in the PipsGrowth line-up. For traders who need a session window, a spread cap, a daily-loss limit, or a partial-close scalping ladder, a different EA in the family is a better fit.
Strategy Deep Dive
On every tick the EA reads two exponential moving averages on the current chart symbol and timeframe and compares the forming bar to the previous bar. A fresh cross at shift 0/1 fires a market order with the fixed lot, the configured stop, and the configured target; a deduplication guard in g_lastSignalTime blocks repeat entries on the same cross candle. The position is then held untouched until either the stop, the target, or a reverse cross takes it out — ManagePositions() walks the position list every tick and force-closes any EA-owned ticket whose direction now disagrees with the live fast/slow state. Order sends and modifications go through TryClose_EX07012 and TryModify_EX07012, which retry up to three times on REQUOTE, TIMEOUT, PRICE_OFF, and PRICE_CHANGED with a 200ms sleep. There is no session, spread, news, or equity-floor gate, so the EA will open or close positions around the clock whenever the averages cross.
The EA enters a long when the current bar's fast EMA crosses above the slow EMA, and a short on the mirror cross below. The cross is detected at shifts 0 and 1 inside DetectSignal(), and the signal time is compared against g_lastSignalTime to ensure only one order per new cross bar. Order size is the fixed InpLotSize (default 0.1); the stop is InpStopLoss points (default 50) and the target is InpTakeProfit points (default 100).
Positions exit on a server-side 50-point stop or 100-point target, whichever is hit first. The EA also closes any open position whose direction now disagrees with the live fast/slow EMA state — ManagePositions() sweeps every tick and force-closes opposing positions with magic 22207012 on the same symbol. There is no trailing, no breakeven ratchet, no partial close, and no time stop.
The hard server-side stop is InpStopLoss points (default 50), placed 50 points below the entry ASK for buys and 50 above the entry BID for sells. Beyond that there is no per-trade stop adjustment; the EA relies on the cross-based exit to close trades that the stop would not catch.
The hard server-side target is InpTakeProfit points (default 100), placed 100 points above the entry ASK for buys and 100 below the entry BID for sells. The default 1:2 SL-to-TP ratio is baked into the input pairing and is not a separately optimized parameter.
This EA fits a $100 minimum account trading 0.1 lots on XAUUSD or FX majors, with the trader accepting that there is no built-in equity or drawdown guard. The default M5 timeframe suits short-term mean-reversion and momentum-confirmation trading; running on H1 is also supported for slower swing entries. The simplicity of the input set makes it a good fit for traders who want a transparent 12/26 EMA crossover signal with no hidden filters, on a low-spread ECN broker that can absorb a 50-point stop without slippage.
Strategy Logic
Pipsgrowth EX07012 MA — Strategy Logic Analysis (from .mq5 source)
Family: MA
Magic: 22207012
Version: 2.00
BRIEF:
EMA crossover EA detecting fast/slow MA cross signals with stop loss, take profit, and automatic position management across a 12-layer architecture. 12 layers: REGIME, SIGNAL, ENTRY, CONFIRM, NO-TRADE, CAPITAL CAP, RISK, SIZING, MANAGE, EXIT, SCALING, OnTester
INDICATOR STACK:
- Standard
MT5indicators
KEY FUNCTIONS:
GetEMAData()IsEMABullish()IsEMABearish()OpenOrder()ClosePositionsByType()ManagePositions()TryClose_EX07012()TryClosePartial_EX07012()TryModify_EX07012()
INTERNAL CONSTANTS (0 total):
INPUT PARAMETERS (10 total across 3 groups):
- [===
EMASettings ===]InpFastPeriod= 12 // FastEMAPeriod - [===
EMASettings ===]InpSlowPeriod= 26 // SlowEMAPeriod - [===
EMASettings ===]InpMethod=MODE_EMA// MA Calculation Method - [===
EMASettings ===]InpAppliedPrice= 1 // Applied price (1=close,2=open,3=high,4=low,5=median,6=typical,7=weighted) // Applied Price - [=== Trading Settings ===]
InpLotSize=0.1// Lot Size - [=== Trading Settings ===]
InpMagicNumber=22207012// Magic Number - [=== Trading Settings ===]
InpTradeComment= "Psgrowth.com Expert_07012" // Trade comment - [=== Trading Settings ===]
InpStopLoss= 50 // StopLoss(points) - [=== Trading Settings ===]
InpTakeProfit= 100 // TakeProfit(points) - [===
EAOptimization ===]InpEAOptimized=true//EAOptimizationMode(Kept for compatibility)
// Pipsgrowth EX07012 MA — Execution Flow (from source analysis)
// Family: MA
// EMA crossover EA detecting fast/slow MA cross signals with stop loss, take profit, and automatic position management across a 12-layer architecture. 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 onto an H4 or Daily chart for best results
- 7Configure EMA periods, ADX threshold, and lot size in the dialog
- 8Enable Allow Algo Trading and click OK
EA Parameters
| Parameter | Default | Description |
|---|---|---|
| InpFastPeriod | 12 | Fast EMA Period |
| InpSlowPeriod | 26 | Slow EMA Period |
| InpMethod | MODE_EMA | MA Calculation Method |
| InpAppliedPrice | 1 | Applied price (1=close,2=open,3=high,4=low,5=median,6=typical,7=weighted) // Applied Price |
| InpLotSize | 0.1 | Lot Size |
| InpMagicNumber | 22207012 | Magic Number |
| InpTradeComment | "Psgrowth.com Expert_07012" | Trade comment |
| InpStopLoss | 50 | Stop Loss (points) |
| InpTakeProfit | 100 | Take Profit (points) |
| InpEAOptimized | true | EA Optimization Mode (Kept for compatibility) |
#property copyright "Pipsgrowth.com"
#property link "https://pipsgrowth.com"
#property version "2.00"
#property strict
#property description "Pipsgrowth.com EX07012 EMA_Crossover_EA — fast/slow EMA crossover with SL/TP, full 12-layer stack."
#include <Trade\Trade.mqh> /* Added Include for Trading */
//+------------------------------------------------------------------+
//| Input Parameters |
//+------------------------------------------------------------------+
ENUM_APPLIED_PRICE MapAppliedPriceInt(int ap)
{
switch(ap)
{
case 1: return PRICE_CLOSE;
case 2: return PRICE_OPEN;
case 3: return PRICE_HIGH;
case 4: return PRICE_LOW;
case 5: return PRICE_MEDIAN;
case 6: return PRICE_TYPICAL;
case 7: return PRICE_WEIGHTED;
default: return PRICE_CLOSE;
}
}
ENUM_APPLIED_PRICE g_InpAppliedPrice = PRICE_CLOSE;
input group "=== EMA Settings ==="
input int InpFastPeriod = 12; // Fast EMA Period
input int InpSlowPeriod = 26; // Slow EMA Period
input ENUM_MA_METHOD InpMethod = MODE_EMA; // MA Calculation Method
input int InpAppliedPrice = 1; // Applied price (1=close,2=open,3=high,4=low,5=median,6=typical,7=weighted) // Applied Price
ENUM_APPLIED_PRICE MapAppliedPriceInt(int ap)
{
switch(ap)
{
case 1: return PRICE_CLOSE;
case 2: return PRICE_OPEN;
case 3: return PRICE_HIGH;
case 4: return PRICE_LOW;
case 5: return PRICE_MEDIAN;
case 6: return PRICE_TYPICAL;
case 7: return PRICE_WEIGHTED;
default: return PRICE_CLOSE;
}
}
ENUM_APPLIED_PRICE g_InpAppliedPrice = PRICE_CLOSE;
input group "=== Trading Settings ==="
input double InpLotSize = 0.1; // Lot Size
input int InpMagicNumber = 22207012; // Magic Number
input string InpTradeComment = "Psgrowth.com Expert_07012"; // Trade comment
input int InpStopLoss = 50; // Stop Loss (points)
input int InpTakeProfit = 100; // Take Profit (points)
ENUM_APPLIED_PRICE MapAppliedPriceInt(int ap)
{
switch(ap)
{
case 1: return PRICE_CLOSE;
case 2: return PRICE_OPEN;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 Trend Following strategy EAs from our library
Pipsgrowth EX16080 Trend
Pipsgrowth.com EX16080 EURUSDTrendFollower — triple-EMA H4 trend follower, full 12-layer stack.
Pipsgrowth EX16081 Trend
Pipsgrowth.com EX16081 GoldTrendEA — XAUUSD H4 EMA cross with Fib targets, full 12-layer stack.
Pipsgrowth EX16033 Trend
Pipsgrowth.com EX16033 EA_Price_Action — price-action grid scalper, full 12-layer stack.
Community
Educational purposes only. Do NOT use with real money. Test on demo accounts only.