Pipsgrowth EX12020 MultiIndicatorConfluence
MT5 Expert Advisor (Open Source) · XAUUSD · M5, H1
Pipsgrowth.com EX12020 BotCilentoV1_35 — MA-based directional grid with risk management, full 12-layer stack.
Overview
Pipsgrowth EX12020 BotCilento is a directional grid EA on the H1 timeframe that drives entries from a fast/slow SMA cross and a series of distinct filters, then layers either a Martingale (1.3× per layer) or arithmetic lot progression on top of a 5-trade grid that can stretch to 10 in extreme circumstances. The EA is shipped under the MultiIndicatorConfluence v2.00 family with magic 22212020, and the underlying source — Pipsgrowth_com_EX12020.mq5 — exposes 46 input parameters and 32 custom functions covering every stage of the trade lifecycle. Despite the MultiIndicatorConfluence family name and the 12-layer header text, the actual logic on the wire is a stateful MA-cross grid with user-selectable lot progression, not a multi-vote indicator confluence.
The signal engine is plain by design. Two SMAs — a 5-period fast and a 20-period slow, both MODE_SMA on PRICE_CLOSE — are pulled from H1 by GetMAValue() and stored in market.maFast and market.maSlow. A buy signal is registered when the chosen reference price (close by default, switchable to bid via Use_Close_Price_Signals) sits above both MAs, with a minimum 15-pip gap between the price and the fast MA. A sell signal is the mirror: price below both MAs with the same 15-pip gap. The Enable_MA_Slope_Filter adds a second gate that demands the fast MA has moved at least 5 pips between bar 1 and bar 2 (MathAbs(maPrevSlope) < (market.pipValue * 5)), killing the flat-zone crossovers that produce repeated false entries in low-volatility sessions. The 15-pip Min_Signal_Distance_Pips gate is what separates a real pullback to the fast MA from a wick that just touches it.
Three additional filters stand between the signal and the order. The volume filter — Volume_Filter_Multiplier at 1.5 by default — requires the current H1 bar's tick volume to be at least 1.5× the previous bar's, eliminating low-participation candles that often reverse on the next bar. The volatility filter compares a 5-period ATR against a 20-period ATR on the current chart timeframe; when the short/long ratio exceeds V_Filter_Threshold (1.5 by default), IsMarketTooVolatile() returns true and entries are blocked. The spread filter caps entries at MaxSpread_In_Pips = 5 pips — the actual spread is read fresh from the symbol each OnTimer cycle (every 5 seconds) and each OnTick, so a momentary spread spike to 8 pips will hold a signal until the spread comes back under 5.
When the no-trade gate is clear, the EA opens the first trade of a cycle — either EnterBuyCycle() or EnterSellCycle(). The cycle state machine tracks the active side, the running weighted-average entry price, the total lots accumulated, and the timestamp of the first trade. The initial lot is Initial_Lot (0.1 by default) passed through NormalizeLot() to enforce the broker's volume step and min/max bounds. From there the EA branches depending on Enable_Grid_Trading. With grid trading enabled (off by default), the EA looks for additional entry opportunities when the live price has moved at least one grid step away from the cycle's weighted-average entry AND the distance from the last grid fill is also at least one grid step. The grid step is either Fixed_Step_In_Pips (50 pips) or, with StepType = ATR_BASED, Step_ATR_Period (14) × Step_ATR_Multiplier (0.5) on the user-selected timeframe (H1 by default). Min_Grid_Step_Pips (20) acts as a hard floor regardless of mode — even if ATR says 8 pips, the grid step won't go below 20.
Each new grid layer calls CalculateNextLotSize(), which scales the initial lot in one of two ways. With LotStrategy = MARTINGALE, the lot for the Nth layer is 0.1 × 1.3^N — at the 5th layer the position is roughly 3.71× the initial lot (about 0.37 lots starting from 0.1). With ARITHMETIC_PROGRESSION (the default), the lot for the Nth layer is 0.1 × (N+1) — at the 5th layer the position is 0.6 lots. The weighted-average entry is recalculated after every fill (state.averageEntryPrice = (state.averageEntryPrice * state.totalLots + market.ask * lot) / (state.totalLots + lot)), so the basket's break-even moves as the grid deepens.
Four independent exit paths run on every tick of an active cycle. CheckForTakeProfit() measures the bid (or ask, for sells) against the basket's average entry plus the TP distance in pips (Take_Profit_In_Pips = 100 by default, or ATR × Step_ATR_Multiplier if ATR step mode is enabled), plus the live spread cost (spreadCost = market.currentSpreadInPips * market.pipValue) to keep net profit positive. CheckForEmergencyClose() watches equity-vs-balance drawdown and force-closes the cycle at Max_Grid_Drawdown_Percent = 20%. CheckForStagnation() looks at the elapsed cycle time and the current distance from the basket average; if 30+ minutes have passed and price has moved fewer than Stagnation_Threshold_Pips = 10 pips from the average, the cycle is force-closed as dead weight. The fourth path, the signal-flip, runs on every OnTick and is gated by Enable_Signal_Flip_Close plus Flip_On_Opposite_Signal. After Min_Cycle_Duration_Minutes = 180 (3 hours) have elapsed since the cycle started, the EA checks the prior H1 bar's close against the MAs; if the close has crossed to the opposite side of both MAs, the cycle is closed and a new cycle is opened on the flip side. The 3-hour minimum prevents the flip from triggering on the first wick against the basket.
The risk envelope is layered. A pre-trade margin check in CheckMargin() enforces a 1.2× margin buffer on top of the broker's minimum free margin requirement (minFreeMarginBuffer = 100 by default) and refuses the trade if account margin level drops below 50%. ExecuteTrade() enforces additional rate limits: 1 trade per second, 1 trade per tick, and a hard skip if state.dailyLossLimitHit is true. The daily loss limit is dual — Daily_Loss_Limit_Percent = 5% OR Daily_Loss_Limit_Dollar if set — and is checked once per hour in CheckDailyReset(). When triggered, every open position on the magic is closed by CloseAllOpenTrades() and CycleCooldownHours = 4 blocks any new cycle. Note that the EA also enforces MinEntryDelayMinutes = 60 between cycle starts as a separate cooldown.
Max_Position_Age_Hours = 72 is the last-resort close. CheckPositionAge() walks positions and force-closes any ticket that has been open longer than 72 trading hours — weekend hours are explicitly subtracted from the age (hoursOpen -= fullWeeks * 48) so the EA doesn't count Friday→Monday as 3 days of exposure. The age check runs every tick.
The order-execution layer is conservative. TryClose_EX12020() and TryClosePartial_EX12020() retry 3 times on REQUOTE, TIMEOUT, PRICE_OFF, and PRICE_CHANGED with a 200ms sleep between attempts. TryModify_EX12020() retries 3 times on REQUOTE and TIMEOUT only (no PRICE_CHANGED retry, asymmetric) with a 100ms sleep. Magic number and slippage (MaxSlippage_In_Pips = 15) are set on the global CTrade trade object in OnInit(). The OnTick() handler also has a price-movement gate: it returns early without re-evaluating signals if (bid+ask)/2 hasn't moved by at least 5 pips since the last processed price — a CPU-saving trick that also prevents the cycle logic from running on every micro-quote update.
One thing to keep in mind: the source carries the standard Pipsgrowth risk warning in the header and prints it to the journal on every init, but the EA's actual risk control is whatever the user sets the inputs to. With grid trading ON, a 1.3× Martingale, and a $100 minimum deposit, a 5-layer XAUUSD basket reaches 0.37 lots total — well within the typical 1:100 leverage envelope, but the 20% drawdown kill-switch is the only line between a trend day against the basket and a margin call. The strategy works best as a one-trade-per-signal directional EA on a $100–$500 account, or as a small-grid averaging EA on a $1,000+ account with a tighter multiplier and a wider MaxSpread.
Strategy Deep Dive
EX12020 runs a directional grid in two phases: a signal phase that fires once per H1 bar from a 5/20 SMA cross with a 15-pip gap, a 5-pip slope filter, a 1.5× volume gate, and a short/long ATR(5)/ATR(20) volatility filter, and a management phase that walks the active cycle through TP, drawdown kill-switch, stagnation close, and signal-flip close on every tick. Lot scaling for grid layers is user-selectable between Martingale (default 1.3× per layer) and arithmetic progression, with the basket's weighted-average entry recomputed after every fill, and the entire cycle is bounded by 20% drawdown, 5% daily loss, 4-hour cooldown, 60-minute between-cycle delay, and a 72-hour position age cap. Order execution is conservative — TryClose_EX12020 retries 3 times on REQUOTE/TIMEOUT/PRICE_OFF/PRICE_CHANGED with 200ms sleeps, TryModify_EX12020 retries on REQUOTE/TIMEOUT only — and the OnTick handler requires the previous tick to have moved at least 5 pips before the next logical pass runs. The strategy deliberately reads H1 bars for signal generation and PERIOD_CURRENT for the volatility ATR comparison, which means the EA is reading a higher-timeframe trend (H1) but measuring the current chart's volatility for the filter — a setup that should be respected when choosing the chart timeframe. With Enable_Grid_Trading off (the default), the EA still works as a single-shot directional EA that opens one trade per signal and closes on TP, drawdown, stagnation, or flip.
EX12020 enters a new buy or sell cycle when the H1 close price sits above (or below) both the 5-period and 20-period SMAs with a minimum 15-pip gap to the fast MA, the fast MA has moved at least 5 pips between bars 1 and 2 (slope filter), the current H1 tick volume is at least 1.5× the previous bar, the short/long ATR(5)/ATR(20) ratio stays under 1.5, and the live spread stays under 5 pips. The cycle is started at the initial 0.1 lot from EnterBuyCycle() or EnterSellCycle(), and the EA will not fire a new cycle within 4 hours of a previous close (cooldown) or within 60 minutes of a previous start. With Enable_Grid_Trading on, additional layers are added when price has moved one grid step (50 pips fixed or ATR(14) × 0.5 on the chosen timeframe, with a 20-pip hard floor) away from the basket's weighted-average entry and at least 30 minutes have elapsed since the last grid fill.
EX12020 exits the cycle on any of four independent paths: basket TP (100 pips or ATR(14) × 0.5 in ATR step mode, with live spread cost added), drawdown kill-switch at 20% equity-to-balance via CheckForEmergencyClose(), stagnation close if 30+ minutes have passed and price is within 10 pips of the basket average (CheckForStagnation()), or a signal-flip close that fires after a minimum 180-minute cycle duration when the H1 close has crossed to the opposite side of both MAs. When the flip is enabled and the close is against the basket, the EA closes the current side and immediately opens a cycle on the opposite side via EnterBuyCycle() or EnterSellCycle(). The 3-hour minimum cycle duration is enforced to keep the flip from triggering on the first wick against the position.
EX12020 has no per-trade stop loss — entries open without SL and TP server-side — and uses a 20% equity-to-balance drawdown kill-switch via CheckForEmergencyClose() as the catastrophic safety net. The Max_Position_Age_Hours = 72 close is the second-line stop, and the 5% daily loss limit plus the 4-hour cycle cooldown prevent re-entry after a stop-out. With Enable_Grid_Trading on and the default Martingale 1.3× multiplier, a 0.1-lot start on XAUUSD builds a ~0.37-lot basket at the 5th layer, so the 20% drawdown cap is the only thing standing between a bad trend day and account depletion.
EX12020's basket take-profit is Take_Profit_In_Pips = 100 pips from the weighted-average entry by default, with the live spread cost added to keep net positive, and switches to ATR(14) × 0.5 automatically when StepType = ATR_BASED so the TP breathes with volatility. The basket-wide TP fires on CheckForTakeProfit() from the bid (buys) or ask (sells) crossing the average entry ± TP, closing the entire cycle in one shot. A second, grid-only profit path — CheckGridProfitClosure() with EnableGridCloseAtProfit = true and GridCloseProfitPips = 10 pips — closes the basket when the live profit-per-pip of the running basket hits 10 pips, designed to bail out small winners before they turn into losers when the trend fails to develop.
Minimum recommended balance: $100 (the EA's margin buffer of 1.2× plus a $100 Min_Free_Margin_Buffer floor scales with broker leverage — on a 1:100 account the absolute floor is higher than on a 1:500, so a $500+ balance gives breathing room). Best deployed on a low-spread ECN or RAW account because the 5-pip MaxSpread_In_Pips cap and the 15-pip Min_Signal_Distance_Pips are tight relative to gold's typical 2–3 pip raw spread on a good broker. With Enable_Grid_Trading on and the default Martingale 1.3× multiplier, a $1,000+ balance is the right call to absorb a 5-layer basket drawdown before the 20% kill-switch fires. Best timing: this is a H1-bar EA, so attach it to the H1 chart on the broker's server time — the IsMarketOpen() guard accepts server hours 1–22, which closes the EA for the Sunday-evening rollover gap and the Friday 22:00+ session, so a London or New York session trader who leaves the EA running across both is the target user.
Strategy Logic
Pipsgrowth EX12020 MultiIndicatorConfluence — Strategy Logic Analysis (from .mq5 source)
Family: MultiIndicatorConfluence
Magic: 22212020
Version: 2.00
BRIEF:
MA-based directional grid EA with optional Martingale or Arithmetic lot progression, managing entries via fast/slow MAs with volatility and slope filters, plus risk constraints. 12 layers: REGIME, SIGNAL, ENTRY, CONFIRM, NO-TRADE, CAPITAL CAP, RISK, SIZING, MANAGE, EXIT, SCALING, OnTester
INDICATOR STACK:
- Standard
MT5indicators
KEY FUNCTIONS:
DebugPrint()SnapshotQuotes()IsMarketOpen()GetMAValue()UpdateIndicators()CheckDailyReset()CheckPositionAge()ExecuteTrade()CheckMargin()CloseAllOpenTrades()CloseAllTradesOfType()ResetCycleState()- ...and 21 more
INTERNAL CONSTANTS (0 total):
INPUT PARAMETERS (46 total across 7 groups):
- [=== General
EASettings ===]MagicNumber=22212020// UniqueEAidentifier - [=== General
EASettings ===]InpTradeComment= "Psgrowth.com Expert_12020" // Trade comment - [=== General
EASettings ===]ShowInfo=true// Show info panel - [=== General
EASettings ===]DebugMode=true// Enable debug logging - [=== Lot Sizing & Grid Settings ===]
LotStrategy=ARITHMETIC_PROGRESSION// Lot sizing strategy - [=== Lot Sizing & Grid Settings ===] Enable_Grid_Trading =
false// Enable grid trading - [=== Lot Sizing & Grid Settings ===] Initial_Lot =
0.1// Initial lot size - [=== Lot Sizing & Grid Settings ===] Martingale_Multiplier =
1.3// Lot multiplier for Martingale - [=== Lot Sizing & Grid Settings ===] Max_Grid_Trades = 5 // Maximum trades in grid
- [=== Lot Sizing & Grid Settings ===] Max_Total_Trades = 10 // Max total trades per cycle
- [=== Lot Sizing & Grid Settings ===] Min_Grid_Step_Pips =
20.0// Minimum grid step in pips - [=== Lot Sizing & Grid Settings ===]
StepType=FIXED_PIPS// Grid step type - [=== Lot Sizing & Grid Settings ===] Fixed_Step_In_Pips =
50.0// Fixed step in pips - [=== Lot Sizing & Grid Settings ===] Step_ATR_Period = 14 //
ATRperiod for step calculation - [=== Lot Sizing & Grid Settings ===] Step_ATR_Multiplier =
0.5//ATRmultiplier for step - [=== Lot Sizing & Grid Settings ===] Step_ATR_Timeframe = 8 //
Timeframe(1=M1,2=M5,3=M15,4=M30,5=H1,6=H4,7=D1) //ATRtimeframe - [=== Trade Entry & Signal Filters ===] Enable_MA_Slope_Filter =
true// Enable MA slope filter - [=== Trade Entry & Signal Filters ===] MA_Fast_Period = 5 // Fast MA period
- [=== Trade Entry & Signal Filters ===] MA_Slow_Period = 20 // Slow MA period
- [=== Trade Entry & Signal Filters ===] Use_Close_Price_Signals =
true// Use closing prices for signals - [=== Trade Entry & Signal Filters ===] Min_Signal_Distance_Pips =
15.0// Min signal distance in pips - [=== Trade Entry & Signal Filters ===] Volume_Filter_Multiplier =
1.5// Volume filter multiplier - [=== Trade Entry & Signal Filters ===] Enable_Volatility_Filter =
true// Enable volatility filter - [=== Trade Entry & Signal Filters ===] V_Filter_Short_ATR = 5 // Short
ATRperiod - [=== Trade Entry & Signal Filters ===] V_Filter_Long_ATR = 20 // Long
ATRperiod - [=== Trade Entry & Signal Filters ===] V_Filter_Threshold =
1.5// Volatility threshold multiplier - [=== Trade Entry & Signal Filters ===]
MaxSpread_In_Pips=5.0// Maximum allowed spread - [=== Trade Entry & Signal Filters ===]
MaxSlippage_In_Pips= 15 // Maximum allowed slippage - [=== Trade Entry & Signal Filters ===] Min_Free_Margin_Buffer =
100.0// Minimum free margin buffer - [=== Take Profit, Cycle & Timing ===] Enable_Signal_Flip_Close =
true// Close trades on signal flip - [=== Take Profit, Cycle & Timing ===] Take_Profit_In_Pips =
100.0// Take profit in pips - [=== Take Profit, Cycle & Timing ===] Flip_On_Opposite_Signal =
true// Close & flip on opposite MA - [=== Take Profit, Cycle & Timing ===] Max_Cycle_Hours = 48 // Max cycle duration (hours)
- [=== Take Profit, Cycle & Timing ===] Min_Cycle_Duration_Minutes = 180 // Min cycle duration before flip
- [=== Take Profit, Cycle & Timing ===]
MinEntryDelayMinutes= 60 // Min minutes between new cycles - [=== Take Profit, Cycle & Timing ===]
MinGridTradeIntervalMinutes= 30 // Min minutes between grid trades - [=== Take Profit, Cycle & Timing ===]
CycleCooldownHours= 4 // Cooldown after cycle close - [=== Take Profit, Cycle & Timing ===] Max_Position_Age_Hours = 72 // Close positions after X hours
- [=== Risk Management ===] Enable_Emergency_Close =
true// Close trades at max drawdown - [=== Risk Management ===] Max_Grid_Drawdown_Percent =
20.0// Max drawdown before close - [=== Risk Management ===] Daily_Loss_Limit_Percent =
5.0// Max daily loss (%) - [=== Risk Management ===] Daily_Loss_Limit_Dollar =
0.0// Max daily loss ($, 0=disable) - [=== Risk Management ===] Max_Trades_Per_Second = 1 // Max trades per second
- [=== Other Conditions ===] Stagnation_Threshold_Pips =
10.0// Stagnation threshold - [=== Grid Profit Closure ===]
EnableGridCloseAtProfit=true// Enable grid closure at profit - [=== Grid Profit Closure ===]
GridCloseProfitPips=10.0// Close grid when profit reaches (pips)
// Pipsgrowth EX12020 MultiIndicatorConfluence — Execution Flow (from source analysis)
// Family: MultiIndicatorConfluence
// MA-based directional grid EA with optional Martingale or Arithmetic lot progression, managing entries via fast/slow MAs with volatility and slope filters, plus risk constraints. 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 | 22212020 | Unique EA identifier |
| InpTradeComment | "Psgrowth.com Expert_12020" | Trade comment |
| ShowInfo | true | Show info panel |
| DebugMode | true | Enable debug logging |
| LotStrategy | ARITHMETIC_PROGRESSION | Lot sizing strategy |
| Enable_Grid_Trading | false | Enable grid trading |
| Initial_Lot | 0.1 | Initial lot size |
| Martingale_Multiplier | 1.3 | Lot multiplier for Martingale |
| Max_Grid_Trades | 5 | Maximum trades in grid |
| Max_Total_Trades | 10 | Max total trades per cycle |
| Min_Grid_Step_Pips | 20.0 | Minimum grid step in pips |
| StepType | FIXED_PIPS | Grid step type |
| Fixed_Step_In_Pips | 50.0 | Fixed step in pips |
| Step_ATR_Period | 14 | ATR period for step calculation |
| Step_ATR_Multiplier | 0.5 | ATR multiplier for step |
| Step_ATR_Timeframe | 8 | Timeframe (1=M1,2=M5,3=M15,4=M30,5=H1,6=H4,7=D1) // ATR timeframe |
| Enable_MA_Slope_Filter | true | Enable MA slope filter |
| MA_Fast_Period | 5 | Fast MA period |
| MA_Slow_Period | 20 | Slow MA period |
| Use_Close_Price_Signals | true | Use closing prices for signals |
| Min_Signal_Distance_Pips | 15.0 | Min signal distance in pips |
| Volume_Filter_Multiplier | 1.5 | Volume filter multiplier |
| Enable_Volatility_Filter | true | Enable volatility filter |
| V_Filter_Short_ATR | 5 | Short ATR period |
| V_Filter_Long_ATR | 20 | Long ATR period |
| V_Filter_Threshold | 1.5 | Volatility threshold multiplier |
| MaxSpread_In_Pips | 5.0 | Maximum allowed spread |
| MaxSlippage_In_Pips | 15 | Maximum allowed slippage |
| Min_Free_Margin_Buffer | 100.0 | Minimum free margin buffer |
| Enable_Signal_Flip_Close | true | Close trades on signal flip |
| Take_Profit_In_Pips | 100.0 | Take profit in pips |
| Flip_On_Opposite_Signal | true | Close & flip on opposite MA |
| Max_Cycle_Hours | 48 | Max cycle duration (hours) |
| Min_Cycle_Duration_Minutes | 180 | Min cycle duration before flip |
| MinEntryDelayMinutes | 60 | Min minutes between new cycles |
| MinGridTradeIntervalMinutes | 30 | Min minutes between grid trades |
| CycleCooldownHours | 4 | Cooldown after cycle close |
| Max_Position_Age_Hours | 72 | Close positions after X hours |
| Enable_Emergency_Close | true | Close trades at max drawdown |
| Max_Grid_Drawdown_Percent | 20.0 | Max drawdown before close |
| Daily_Loss_Limit_Percent | 5.0 | Max daily loss (%) |
| Daily_Loss_Limit_Dollar | 0.0 | Max daily loss ($, 0=disable) |
| Max_Trades_Per_Second | 1 | Max trades per second |
| Stagnation_Threshold_Pips | 10.0 | Stagnation threshold |
| EnableGridCloseAtProfit | true | Enable grid closure at profit |
| GridCloseProfitPips | 10.0 | Close grid when profit reaches (pips) |
#property copyright "Pipsgrowth.com"
#property link "https://pipsgrowth.com"
#property version "2.00"
#property strict
#property description "Pipsgrowth.com EX12020 BotCilentoV1_35 — MA-based directional grid with risk management, full 12-layer stack."
// Include standard MQL5 libraries for trading, indicators, etc.
#include <Trade\Trade.mqh>
#include <Indicators\Trend.mqh>
#include <Indicators\Volumes.mqh>
#include <Indicators\Indicators.mqh>
// ------------------------------
// Enums (User-selectable options)
// ------------------------------
// Defines the lot sizing strategy options
enum ENUM_LOT_STRATEGY
{
MARTINGALE, // Martingale (exponential lot increase)
ARITHMETIC_PROGRESSION // Arithmetic (linear lot increase)
};
// Defines the grid step type options
enum ENUM_STEP_TYPE
{
FIXED_PIPS, // Fixed distance between grid trades in pips
ATR_BASED // Dynamic distance based on ATR indicator
};
// ------------------------------
// Structs (Data containers)
// ------------------------------
// Contains all configurable parameters for the EA
struct TradeConfig
{
bool enableEmergencyClose; // Enable emergency close at max drawdown
bool enableSignalFlipClose; // Close trades on opposite signal
int magicNumber; // Unique EA identifier
string eaComment; // Comment attached to trades
double initialLot; // Starting lot size
double martingaleMultiplier; // Multiplier for martingale strategy
int maxGridTrades; // Maximum trades in a grid
double fixedStepInPips; // Fixed step between grid trades in pips
int stepATRPeriod; // ATR period for step calculation
double stepATRMultiplier; // Multiplier for ATR step
ENUM_TIMEFRAMES stepATRTimeframe; // Timeframe for ATR step
double takeProfitInPips; // Take profit in pips
double stagnationThresholdPips; // Threshold for stagnation close
double maxSpreadInPips; // Maximum allowed spread
int maxSlippageInPips; // Maximum allowed slippage
double minFreeMarginBuffer; // Minimum free margin required
double maxGridDrawdownPercent; // Max drawdown before emergency close
bool flipOnOppositeSignal; // Flip position on opposite signal
int maxCycleHours; // Maximum cycle duration in hours
bool enableVolatilityFilter; // Enable volatility filter
int vFilterShortATR; // Short ATR period for volatility filter
int vFilterLongATR; // Long ATR period for volatility filter
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.