Pipsgrowth EX18105 TrendFollow
MT5 Expert Advisor (Open Source) · XAUUSD · M1, H1
Pipsgrowth.com EX18105 MM3_0_FLIP_CODEPRO — AI SAR scalper with trailing and reverse mode, full 12-layer stack.
Overview
Pipsgrowth EX18105 TrendFollow is an fxDreema-built Expert Advisor that turns a textbook SMA crossover into a 9-leg stacked entry, then manages the resulting basket with a server-agnostic virtual trailing stop and a 7-day order expiry. The filename suffix MM3_0_FLIP_CODEPRO is the visual-block template that generated the .mq5 — every trading decision runs through a graph of 46 CBlockCalls derivatives (Block0 through Block45) wired by the fxDreema export rather than hand-written MQL5 logic. The visible behavior, however, is straightforward: a single bar's SMA(10) vs SMA(50) relationship decides whether the EA buys, sells, sits flat, or flattens an open basket.
Entry is gated by Block0, a no-position check that iterates TradesTotal() and reports whether anything is open on the chart's symbol. When Block0 reports no position, control passes to Block2 (long condition) and Block3 (short condition). Block2 is an MDL_Condition wrapper around two MDLIC_indicators_iMA instances: Lo runs iMA(_Symbol, _Period, 10, 0, MODE_SMA, PRICE_CLOSE, 1) and Ro runs the same call with MAperiod=50; both use Shift=1, so the comparison is between the SMA(10) and SMA(50) of the prior closed bar. Block2's compare operator is ">" and Block3's is "<" — the relationship inverts cleanly. A long crossover fans out to nine parallel buy blocks (Block4, Block10, Block14, Block18, Block22, Block24, Block26, Block28, Block30, Block32) and a short crossover fans out to nine mirror sell blocks (Block5, Block11, Block15, Block19, Block23, Block25, Block27, Block29, Block31, Block33). Each parallel leg is its own MDL_BuyNow or MDL_SellNow instance with a distinct volume extern — inp11_VolumeSize through inp118_VolumeSize — all defaulted to 0.01 lots in the input panel. MagicStart=22218105 is added to the leg's Group integer, so the broker sees nine separate position tickets per signal but they all belong to this EA's namespace.
Exit logic is symmetric. Block1, the if-position check, runs in parallel with Block0 and cascades to Block8 and Block9 — the same SMA(10) vs SMA(50) condition classes with the inverted comparison. When SMA(10) crosses below SMA(50) on the closed bar, Block8 fires Block6, an MDL_CloseOpened instance that walks the position list and closes every long ticket belonging to the magic namespace. Block9 handles the opposite direction with Block7 closing shorts. There is no fixed take-profit — TakeProfitMode is set to "none" in every buy and sell block, and StopLossMode is also "none" on the live ticket. The only protective layer is VirtualStopsDriver, which is invoked on every OnTick() when USE_VIRTUAL_STOPS is true. VirtualStopsDriver draws a trendline object on the chart at trade entry and uses it as a virtual stop: once price moves 50 pips in profit (inpTrailStartPips=50.0), the trailing line ratchets 10 pips (inpTrailStepPips=10.0) and parks 20 pips behind price (inpTrailStopPips=20.0). Because the stop is virtual, the broker never sees a server-side SL — a chart crash or terminal disconnect erases the trailing line.
Order expiration is built into the MDL_BuyNow and MDL_SellNow templates: dExp.ModeTimeShift=2 (relative shift), dExp.TimeShiftDays=1.0, TimeSkipWeekdays=true, then ExpMode="specified" with ExpDays=7, ExpHours=0 on top. The effective behavior is "expire 7 days from entry, skipping weekends." Position-level modifications pass through TryClose_EX18105, TryClosePartial_EX18105, and TryModify_EX18105 retry helpers, each running up to three attempts at 100–200 ms intervals to absorb transient requotes.
A few quirks are worth knowing. ENABLE_SPREAD_METER is true, so the EA draws a live spread overlay on the chart during non-tester runs; ENABLE_STATUS draws a top-left status banner. OnTester() is not implemented, so optimization is driven by the strategy tester's standard profit/drawdown objective. The brief in the source header claims an "AI SAR" entry, but no Parabolic SAR call exists in the code — the actual signal is the iMA SMA(10)/SMA(50) crossover, so trust the source rather than the marketing line. Because every position exits only when the SMA flips or the 7-day timer fires, the EA's holding period is structurally long and is a poor match for traders who expect minute-scale scalping turnover despite the "scalper" label in the brief.
The nine-parallel-leg design is the defining structural choice. In a single buy event the EA opens 9 × 0.01 lots = 0.09 lots of exposure with the same magic prefix, all tracking the same SMA crossover. The virtual trailing stop treats them as one combined position (VirtualStopsDriver walks all matching tickets), and the close block flattens all nine in a single pass. Operators who want tighter risk should lower all nine inp_VolumeSize externs together — the structure is monolithic, so changing one leg's size without the others creates an unbalanced basket.
For backtesting, the lack of an OnTester() function means MT5 falls back to its built-in optimization objective, which by default weights profit factor and total net profit. Because all nine legs open simultaneously on every crossover, the resulting equity curve tends to step up on each clean SMA(10)/SMA(50) flip and bleed slowly between signals; this is the visual signature of a basket system rather than a single-ticket EA. The spread overlay (ENABLE_SPREAD_METER) and the top-left status banner (ENABLE_STATUS) are only drawn outside the strategy tester, so visual sanity checks require a demo account run. ENABLE_TEST_INDICATORS controls whether tester-mode charts still render the FXD graphical objects, but the only indicator the EA actually creates is the iMA buffer inside the MDL_Condition wrappers — there are no separate iCustom handles, no chart-attached oscillators, and no subwindow panes to inspect.
The OCO (one-cancels-other) driver runs in the background of OnTick() and is the silent backstop for accidental duplicate positions: if a tick fires Block0's no-position check while a residual position is being closed, OCODriver() will keep the open and the close request from racing. The OCO behaviour is automatic and not exposed via inputs, so it is worth knowing it is there but not worth tuning.
Strategy Deep Dive
On every tick, OnTick() increments the FXD_TICKS_FROM_START counter, runs VirtualStopsDriver() to update every open position's trailing line, and then fires Block0 (no-position check) and Block1 (has-position check). A long crossover of SMA(10) over SMA(50) on the closed bar launches nine parallel MDL_BuyNow blocks reading from inp11/inp17/inp101...inp108 VolumeSize externs; a short crossover launches nine MDL_SellNow blocks reading from inp12/inp18/inp111...inp118. Block1 watches for the opposite crossover and triggers the matching MDL_CloseOpened block to flatten the entire 9-leg basket in one pass. All nine legs share the magic prefix 22218105 plus a Group offset, so VirtualStopsDriver trails them as a single combined exposure, and the 7-day expiration (ExpMode='specified' with ExpDays=7) is the only time-based close. There is no OnTester, no regime classifier, no information panel, and no news filter — every trading decision flows through the fxDreema block graph rather than hand-written indicator logic.
A long entry fires when the prior bar's iMA(SMA, period=10, applied=CLOSE, shift=1) closes above the prior bar's iMA(SMA, period=50, applied=CLOSE, shift=1); a short entry fires on the inverse relationship. Because the no-position check (Block0) must be empty, the EA enters at most one direction at a time, and on that signal it opens nine parallel buy (or sell) tickets — each with its own inp_VolumeSize extern, all defaulted to 0.01 lots, all sharing the magic prefix 22218105 plus the group offset.
Exit is triggered by the inverse SMA(10)/SMA(50) relationship on the prior closed bar. When the crossover flips, an MDL_CloseOpened pass walks every position in the magic namespace and flattens all nine legs in a single sweep. There is no fixed take-profit on the ticket; profit is harvested by the virtual trailing stop (50 pip activation, 10 pip step, 20 pip distance) or by the 7-day order expiration as a final safety net.
No server-side stop-loss is ever attached. The protective layer is VirtualStopsDriver, which draws a trendline at entry and uses it as a virtual trailing stop, and EMERGENCY_STOPS_REL=0 hard-confirms there is no fallback hard stop. Account-level stop-out at the broker is the only true backstop.
TakeProfitMode is set to 'none' on every buy and sell block, so no fixed take-profit is attached. Profits are realised by the SMA-flip exit (which closes all nine legs), by the virtual trailing stop catching a trend extension, or by the 7-day order expiration as a last-resort close.
Best deployed on XAUUSD M1 for aggressive turnover, or XAUUSD H1 for a calmer swing-style cadence; the 50/10/20 pip trail is sized for gold's volatility and will be hit constantly on FX majors at the same pip distance. Recommended balance is $100 for a single-group run; running all nine buy and nine sell groups live at 0.01 lot each pushes margin demand to roughly $90 per side, so plan for at least $300 to keep breathing room. Broker: ECN/raw-spread with deep liquidity and a reliable VPS — the virtual-stop design means a terminal crash or chart removal will erase the trailing line, so an account-level stop-out set as a hard backstop is essential.
Strategy Logic
Pipsgrowth EX18105 TrendFollow — Strategy Logic Analysis (from .mq5 source)
Family: TrendFollow
Magic: 22218105
Version: 2.00
BRIEF:
AI SAR scalper EA with trailing logic and reverse mode. Uses Parabolic SAR for entry signals with custom volume sizing, virtual stops, and multi-group trade management. Built with fxDreema. 12 layers: REGIME, SIGNAL, ENTRY, CONFIRM, NO-TRADE, CAPITAL CAP, RISK, SIZING, MANAGE, EXIT, SCALING, OnTester
INDICATOR STACK:
- Standard
MT5indicators
KEY FUNCTIONS:
OnTrade()OnTimer()OnChartEvent()AccountBalance()AccountBalanceAtStart()AccountEquity()AccountFreeMargin()AlignLots()AlignStopLoss()AlignTakeProfit()ArrayEnsureValue()ArraySearch()- ...and 114 more
INTERNAL CONSTANTS (10 total):
ENABLE_TEST_INDICATORS=true// --ENABLE_EVENT_TICK= 1 // enable "Tick" eventENABLE_EVENT_TRADE= 1 // enable "Trade" eventENABLE_EVENT_TIMER= 1 // enable "Timer" eventVIRTUAL_STOPS_ENABLED= 1 // enable virtual stopsVIRTUAL_STOPS_TIMEOUT= 1 // virtual stops timeoutEMERGENCY_STOPS_REL= 0 // use 0 to disable hard stops when virtual stops are enabled. Use a value >=0 to automatically set hard stops with virtual. Example: if 2 is used, then hard stops will be 2 times bigger than virtual ones.EMERGENCY_STOPS_ADD= 0 // add pips to relative size of emergency stops (hard stops)ON_TIMER_PERIOD= 60 // Timer event period (in seconds)SEL_INITIAL= 1 // Input parameters for trailing stops
INPUT PARAMETERS (7 total across 1 groups):
- []
EnableVirtualStops=true// Enable Virtual Stops - []
VirtualStopsTimeout= 0 // Virtual StopsTimeout(seconds) - []
inpTrailStartPips=50.0// TrailStart(pips) - []
inpTrailStepPips=10.0// TrailStep(pips) - []
inpTrailStopPips=20.0// TrailStop(pips) - []
MagicStart=22218105// Magic Number, kind of... - []
InpTradeComment= "Psgrowth.com Expert_18105" // TradeComment
// Pipsgrowth EX18105 TrendFollow — Execution Flow (from source analysis)
// Family: TrendFollow
// AI SAR scalper EA with trailing logic and reverse mode. Uses Parabolic SAR for entry signals with custom volume sizing, virtual stops, and multi-group trade management. Built with fxDreema. 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 |
|---|---|---|
| EnableVirtualStops | true | Enable Virtual Stops |
| VirtualStopsTimeout | 0 | Virtual Stops Timeout (seconds) |
| inpTrailStartPips | 50.0 | Trail Start (pips) |
| inpTrailStepPips | 10.0 | Trail Step (pips) |
| inpTrailStopPips | 20.0 | Trail Stop (pips) |
| MagicStart | 22218105 | Magic Number, kind of... |
| InpTradeComment | "Psgrowth.com Expert_18105" | Trade Comment |
#property copyright "Pipsgrowth.com"
#property link "https://pipsgrowth.com"
#property version "2.00"
#property strict
#property description "Pipsgrowth.com EX18105 MM3_0_FLIP_CODEPRO — AI SAR scalper with trailing and reverse mode, full 12-layer stack."
#include <Trade\Trade.mqh>
/************************************************************************************************************************/
// +------------------------------------------------------------------------------------------------------------------+ //
// | INPUT PARAMETERS, GLOBAL VARIABLES, CONSTANTS, IMPORTS and INCLUDES | //
// | System and Custom variables and other definitions used in the project | //
// +------------------------------------------------------------------------------------------------------------------+ //
/************************************************************************************************************************/
//VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV//
// System constants (project settings) //
//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^//
//--
#define PROJECT_ID "mt5-3059"
//--
// Point Format Rules
#define POINT_FORMAT_RULES "0.001=0.01,0.00001=0.0001,0.000001=0.0001" // this is deserialized in a special function later
#define ENABLE_SPREAD_METER true
#define ENABLE_STATUS true
#define ENABLE_TEST_INDICATORS true
//--
// Events On/Off
#define ENABLE_EVENT_TICK 1 // enable "Tick" event
#define ENABLE_EVENT_TRADE 1 // enable "Trade" event
#define ENABLE_EVENT_TIMER 1 // enable "Timer" event
//--
// Virtual Stops
#define VIRTUAL_STOPS_ENABLED 1 // enable virtual stops
#define VIRTUAL_STOPS_TIMEOUT 1 // virtual stops timeout
#define USE_EMERGENCY_STOPS "yes" // "yes" to use emergency (hard stops) when virtual stops are in use. "always" to use EMERGENCY_STOPS_ADD as emergency stops when there is no virtual stop.
#define EMERGENCY_STOPS_REL 0 // use 0 to disable hard stops when virtual stops are enabled. Use a value >=0 to automatically set hard stops with virtual. Example: if 2 is used, then hard stops will be 2 times bigger than virtual ones.
#define EMERGENCY_STOPS_ADD 0 // add pips to relative size of emergency stops (hard stops)
//--
// Settings for events
#define ON_TIMER_PERIOD 60 // Timer event period (in seconds)
//VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV//
// System constants (predefined constants) //
//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^//
//--
#define TLOBJPROP_TIME1 801
#define OBJPROP_TL_PRICE_BY_SHIFT 802
#define OBJPROP_TL_SHIFT_BY_PRICE 803
#define OBJPROP_FIBOVALUE 804
#define OBJPROP_FIBOPRICEVALUE 805
#define OBJPROP_FIRSTLEVEL 806
#define OBJPROP_TIME1 807
#define OBJPROP_TIME2 808
#define OBJPROP_TIME3 809
#define OBJPROP_PRICE1 810
#define OBJPROP_PRICE2 811
#define OBJPROP_PRICE3 812
#define OBJPROP_BARSHIFT1 813
#define OBJPROP_BARSHIFT2 814
#define OBJPROP_BARSHIFT3 815
#define SEL_CURRENT 0
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.