Pipsgrowth EX15022 SMC-OrderBlock
MT5 Expert Advisor (Open Source) · XAUUSD · M5, H1
Pipsgrowth.com EX15022 MarketPredictor — FFT/fractal + Monte Carlo price prediction scalper, full 12-layer stack.
Overview
Pipsgrowth EX15022 MarketPredictor is a research-flavored scalper whose trading signal is generated by a Monte Carlo price simulation rather than by the usual technical-indicator stack. The header comment advertises a 12-layer system (REGIME, SIGNAL, ENTRY, CONFIRM, NO-TRADE, CAPITAL CAP, RISK, SIZING, MANAGE, EXIT, SCALING, OnTester), but a careful read of the source shows that the live decision path reduces to two operations: every incoming tick, OptimizeParameters() rewrites the internal model coefficients, then PredictNextPrice() runs SimulatePrice() and forwards a single predicted price to ExecuteTrade(). The Sinusoidal, Fractal (FFT) and Sigmoid components that the header hints at are implemented as standalone functions — CalculateSinComponent, CalculateFractalComponentFFT, CalculateSigmoidComponent — but in PredictNextPrice their return values are computed and discarded (the source keeps the assignment lines commented out, leaving the Monte Carlo path as the only signal source wired into ExecuteTrade).
The Monte Carlo engine is the heart of the EA. SimulatePrice() seeds nothing itself, but OnInit() calls MathSrand((int)TimeCurrent()) so each EA session gets its own pseudo-random stream. Inside the loop, the function generates MonteCarloSimulations = 1000 draws. Each draw produces a random uniform factor between −0.5 and 0.5 by way of MathRand()/32767.0 − 0.5, multiplies that factor by the internal sigma variable (default 10.0), and adds the perturbation to P_t (the latest Bid). The mean of those 1000 perturbed prices is then returned as P_t1, the predicted next price. Because every draw is centred on P_t with a small symmetric perturbation, the average sits very close to the current Bid, so the only way the prediction can escape the ±sigma envelope is when MathRand bias happens to push the average over the threshold on a particular tick — which is exactly what ExecuteTrade() tests for.
The threshold logic in ExecuteTrade() is asymmetric. A buy is opened when P_t1 > currentPrice + sigma and no position is open on the symbol; a sell is opened when P_t1 < currentPrice − sigma and no position is open. The PositionSelect(_Symbol) guard means the EA never pyramids or hedges on the same chart: every fill is followed by a wait for the next entry signal. The orders themselves are raw OrderSend calls with TRADE_ACTION_DEAL, ORDER_TYPE_BUY or ORDER_TYPE_SELL, fixed volume 0.1, deviation 10 points, magic 22215022, and the comment 'Psgrowth.com Expert_15022'. The request does not populate request.sl or request.tp, so positions are placed with no stop-loss and no take-profit on the broker side. There is no CTrade wrapper used on the live entry path — the file declares CTrade g_trade_wrappers_EX15022 at the bottom, but ExecuteTrade bypasses it in favour of direct OrderSend.
OptimizeParameters() is invoked on every tick, not on a new-bar close, so the model coefficients are constantly re-anchored. The function calls CopyClose over the most recent 14 bars, computes a simple moving average, and assigns the result to the internal mu variable, overriding inputMu for the rest of that tick cycle. It also calls iATR(_Symbol, PERIOD_CURRENT, 14) and, if a positive ATR is available, sets alpha to 0.1 × ATR; otherwise alpha falls back to the input value inputAlpha. The other inputs — inputBeta (Fractal weight, default 0.1), inputGamma (Fractal damping, default 0.1), inputKappa (Sigmoid sensitivity, default 1.0) — are loaded once in OnInit into their corresponding internal variables and never touched again on the live path because the components that consume them are commented out. Adjusting those four parameters from the MT5 input dialog therefore only changes a value the live code never reads again after OnInit returns.
The CalculateFractalComponentFFT() function is the only place where the FFT machinery is wired in. It pulls 128 closing prices (N = 128, a power of two) with CopyClose, packages them into a Complex[] array (real part = close, imaginary part = 0), and calls FFT(data, false). FFT is a textbook recursive Cooley–Tukey implementation that splits the array into even and odd indexed sub-arrays, recurses into both, recombines them with complex twiddle factors MathCos/MathSin(2πk/n), and only divides by 2 in the inverse direction. After the transform, CalculateFractalComponentFFT computes the magnitude spectrum, scans indices 1..N/2 to find the dominant frequency (skipping the DC component at index 0), and returns beta × (maxIndex / N). The return value is the predicted-fractal price offset, but the live code does not use it.
CalculateSinComponent() and CalculateSigmoidComponent() follow the same pattern of being defined but inactive. Sin picks a random omega in [0, 2π] per call and returns alpha × sin(omega × t) where t is the bar count. Sigmoid fetches iATR(_Symbol, PERIOD_CURRENT, 14) and computes Delta_t / (1 / (1 + exp(−kappa × (P_t_local − mu)))). Both functions are reachable only from PredictNextPrice, and in PredictNextPrice the lines that would assign and combine them are commented out. The result is a file that reads like a research notebook: the math is all there, but the trading logic itself is the much simpler P_t + random-perturbation comparison against ±sigma.
The 3 retry helpers at the bottom of the file — TryClose_EX15022, TryClosePartial_EX15022, TryModify_EX15022 — are not invoked anywhere in the source. Each loops up to 3 times, calls g_trade_wrappers_EX15022.PositionClose / PositionClosePartial / PositionModify, retries on TRADE_RETCODE_REQUOTE, TRADE_RETCODE_TIMEOUT, TRADE_RETCODE_PRICE_OFF or TRADE_RETCODE_PRICE_CHANGED with 200 ms or 100 ms Sleep, and breaks on any other retcode. They exist as scaffolding for a future SL/TP management layer that the current build does not implement. There is no breakeven, no trailing stop, no time-based exit, no basket close, no equity stop, and no daily-loss cap. A position opened by ExecuteTrade stays open until the broker-side margin call or the trader intervenes manually.
The minDeposit recommendation in the database is $100 and the riskLevel is MEDIUM, which is a reasonable starting point given the 0.1-lot fixed size, the absence of protective orders, and the sigma threshold that gates entries. Users who want the EA to actually fire on a typical gold chart need to be aware that the default sigma = 10.0 is denominated in raw price units, not in pips, so on XAUUSD the ±10 envelope is roughly ±$1 of price movement and the Monte Carlo mean rarely escapes it. Tightening sigma to 0.5 or 1.0, or widening the prediction by adjusting MonteCarloSimulations and the random-factor range, is the practical lever — the input dialog is the only place to make those changes. A reader studying the source should treat the SMC-OrderBlock family label as historical and the 12-layer claim as design intent: what runs in the Strategy Tester is a Monte Carlo threshold-crossing system with no broker-side stops.
Strategy Deep Dive
OnInit seeds MathSrand with TimeCurrent and stores the latest Bid as P_t. OnTick calls OptimizeParameters() first, which copies 14 closing prices, recomputes mu as their simple average, recomputes alpha as 0.1 × iATR(14) when ATR is positive, and otherwise leaves alpha at its input default. PredictNextPrice() then refreshes P_t from SYMBOL_BID, calls SimulatePrice() to average 1000 random uniform perturbations of P_t in a sigma-weighted envelope, and hands the resulting P_t1 to ExecuteTrade(). ExecuteTrade() compares P_t1 to currentPrice and fires a single 0.1-lot market order if the prediction escapes the ±sigma threshold on the appropriate side. The Sinusoidal, Fractal (FFT), and Sigmoid component functions are defined in the file but commented out of the live path, so the only mathematical model actually running is the Monte Carlo average plus the ±sigma threshold test. The three CTrade retry helpers at the bottom of the file (TryClose_EX15022, TryClosePartial_EX15022, TryModify_EX15022) are defined but not wired into the live entry/exit path, so position management beyond the initial fill is left to the broker and the trader.
On every tick the EA calls OptimizeParameters() to re-anchor mu to a 14-bar SMA and alpha to 0.1 × ATR(14), then runs SimulatePrice() to average 1000 random P_t ± uniform[-0.5, 0.5] × sigma perturbations. ExecuteTrade() opens a buy if the predicted price exceeds currentPrice + sigma and there is no open position on the symbol, or a sell if it falls below currentPrice − sigma. The fill is a raw OrderSend with volume 0.1, deviation 10 points, magic 22215022, and no SL/TP attached.
There is no programmed exit. The position stays open until the broker's margin call or until the trader closes it manually. ExecuteTrade() never reverses or scales out a position; the only entry-side guard is PositionSelect(_Symbol), which prevents stacking a second position in the same direction.
No stop-loss is attached. The OrderSend request does not populate request.sl, so positions carry no broker-side protective stop. The header lists RISK and EXIT among the 12 layers, but neither is implemented in the live code path.
No take-profit is attached. The OrderSend request does not populate request.tp either, so winning positions are closed only by the broker (margin call) or by manual intervention. The reverse-signal logic that would close a winner does not exist in this build.
Minimum recommended balance $100, MEDIUM risk, XAUUSD on M5 or H1 (the source suggests M5 works M5–H1 and lists FX majors and gold/metals as portable). Because the Monte Carlo mean sits within a fraction of a pip of the current Bid and the default sigma=10.0 is denominated in raw price units, traders who want this EA to actually fire should lower sigma substantially (e.g. 0.5–2.0 on XAUUSD) and run it on an ECN/RAW-spread account with low latency. The absence of broker-side stops means this is an educational/research EA — keep position size at 0.1 lot and monitor manually until risk controls are added.
Strategy Logic
Pipsgrowth EX15022 SMC-OrderBlock — Strategy Logic Analysis (from .mq5 source)
Family: SMC-OrderBlock
Magic: 22215022
Version: 2.00
BRIEF:
Market-predictor EA using sinusoidal + fractal (FFT) price components with Monte Carlo simulations and parameter optimiza- tion to forecast next-price direction, placing buy/sell when predicted price exceeds a sigma threshold. 12 layers: REGIME, SIGNAL, ENTRY, CONFIRM, NO-TRADE, CAPITAL CAP, RISK, SIZING, MANAGE, EXIT, SCALING, OnTester
INDICATOR STACK:
- Standard
MT5indicators
KEY FUNCTIONS:
CalculateSinComponent()CalculateFractalComponentFFT()CalculateSigmoidComponent()SimulatePrice()PredictNextPrice()ExecuteTrade()OptimizeParameters()FFT()TryClose_EX15022()TryClosePartial_EX15022()TryModify_EX15022()
INTERNAL CONSTANTS (0 total):
INPUT PARAMETERS (9 total across 2 groups):
- [=== Identity ===]
magicNumber=22215022// Magic Number - [=== Identity ===]
InpTradeComment= "Psgrowth.com Expert_15022" // TradeComment - [=== Strategy Parameters ===]
inputAlpha=0.1// Amplitude for the Sinusoidal component - [=== Strategy Parameters ===]
inputBeta=0.1// Weight for the Fractal component - [=== Strategy Parameters ===]
inputGamma=0.1// Damping constant for the Fractal component - [=== Strategy Parameters ===]
inputKappa=1.0// Sensitivity parameter for the Sigmoid function - [=== Strategy Parameters ===]
inputMu=1.0// Mean of price movements - [=== Strategy Parameters ===]
inputSigma=10.0// Threshold for Buy/Sell - [=== Strategy Parameters ===]
MonteCarloSimulations= 1000 // Number of Monte Carlo simulations
// Pipsgrowth EX15022 SMC-OrderBlock — Execution Flow (from source analysis)
// Family: SMC-OrderBlock
// Market-predictor EA using sinusoidal + fractal (FFT) price components with Monte Carlo simulations and parameter optimiza- tion to forecast next-price direction, placing buy/sell when predicted price exceeds a sigma threshold. 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 a chart matching the recommended timeframe
- 7Configure parameters according to the table on this page
- 8Enable Allow Algo Trading and click OK
EA Parameters
| Parameter | Default | Description |
|---|---|---|
| magicNumber | 22215022 | Magic Number |
| InpTradeComment | "Psgrowth.com Expert_15022" | Trade Comment |
| inputAlpha | 0.1 | Amplitude for the Sinusoidal component |
| inputBeta | 0.1 | Weight for the Fractal component |
| inputGamma | 0.1 | Damping constant for the Fractal component |
| inputKappa | 1.0 | Sensitivity parameter for the Sigmoid function |
| inputMu | 1.0 | Mean of price movements |
| inputSigma | 10.0 | Threshold for Buy/Sell |
| MonteCarloSimulations | 1000 | Number of Monte Carlo simulations |
#property copyright "Pipsgrowth.com"
#property link "https://pipsgrowth.com"
#property version "2.00"
#property strict
#property description "Pipsgrowth.com EX15022 MarketPredictor — FFT/fractal + Monte Carlo price prediction scalper, full 12-layer stack."
#include <Trade\Trade.mqh>
// Structure to represent complex numbers
struct Complex
{
double re; // Real part of the complex number
double im; // Imaginary part of the complex number
};
// Input parameters that can be adjusted by the user
input group "=== Identity ==="
input int magicNumber = 22215022; // Magic Number
input string InpTradeComment = "Psgrowth.com Expert_15022"; // Trade Comment
input group "=== Strategy Parameters ==="
input double inputAlpha = 0.1; // Amplitude for the Sinusoidal component
input double inputBeta = 0.1; // Weight for the Fractal component
input double inputGamma = 0.1; // Damping constant for the Fractal component
input double inputKappa = 1.0; // Sensitivity parameter for the Sigmoid function
input double inputMu = 1.0; // Mean of price movements
input double inputSigma = 10.0; // Threshold for Buy/Sell
input int MonteCarloSimulations = 1000; // Number of Monte Carlo simulations
// Internal variables to store optimized parameters
double alpha;
double beta;
double gamma;
double kappa;
double mu;
double sigma;
// Global variable to store the current price
double P_t;
//+------------------------------------------------------------------+
//| Expert initialization function |
//+------------------------------------------------------------------+
int OnInit()
{
// Initialize internal variables with input values
alpha = inputAlpha;
beta = inputBeta;
gamma = inputGamma;
kappa = inputKappa;
mu = inputMu;
sigma = inputSigma;
// Initialize the current price with the symbol's current Bid price
P_t = SymbolInfoDouble(_Symbol, SYMBOL_BID);
// Seed the random number generator with the current time
MathSrand((int)TimeCurrent());
// Additional initializations can be added here if necessary
return(INIT_SUCCEEDED); // Return initialization status
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 Other strategy EAs from our library
Pipsgrowth EX01007 Adaptive
Pipsgrowth.com EX01007 Adaptive XAUUSD 5M — multi-indicator signal scorer with regime filter, full 12-layer stack, configurable timeframe, trailing/BE/profit-lock toggles, pyramid gate, spread filter, new-bar gate, filling mode detection.
Pipsgrowth EX01019 Adaptive
Pipsgrowth.com EX01019 Self-Adaptive Market EA Fixed — multi-regime adaptive EA, full 12-layer stack.
Pipsgrowth EX15029 SMC-OrderBlock
Pipsgrowth.com EX15029 SMCBreakoutEA — SMC breakout CHOCH/liquidity sweep EA, full 12-layer stack.
Community
Educational purposes only. Do NOT use with real money. Test on demo accounts only.