P
PipsGrowth
ScalpingOpen Source – Free

Pipsgrowth EX14018 Scalper

MT5 Expert Advisor (Open Source) · XAGUSD · M15

Pipsgrowth.com EX14018 SilverScalper InsideBar ConsolidationBreak — Silver inside bar breakout scalper with safe pyramiding and SuperTrend filter, full 12-layer stack.

Overview

Pipsgrowth EX14018 is a silver-specific scalper built around the inside bar consolidation breakout pattern, with an unusual safety gate on pyramiding: a position can only be added after the existing stop loss has been ratcheted into profit. Where most breakout EAs treat the first entry as the only entry, this one deliberately scales up — but only when risk is genuinely locked. The combination of inside bar detection, ATR-driven stops, and a SuperTrend trend filter is calibrated for XAGUSD on M15, and the spread ceiling (40 pips, widened for silver's typical quote noise) reflects the same instrument-specific tuning.

The strategy core sits in DetectInsideBar(). Each new M15 bar is checked against the previous bar: if the current bar's high is below the previous bar's high AND its low is above the previous bar's low, the previous bar is recorded as the mother bar (motherHigh, motherLow) and insideBarDetected flips true. The mother bar's range becomes the breakout range. The inside bar itself is the consolidation — typically a pause after a directional move, or a coil before a news event. When the close of a subsequent bar exceeds motherHigh + BreakoutBuffer * pipSize (15 pips default), a long entry fires; a close below motherLow - BreakoutBuffer * pipSize fires a short. The 15-pip buffer is larger than what a similar inside bar EA would use on EURUSD, because silver can whip through 5–10 pips of noise on a single tick and a tight buffer would generate false breakouts.

When UseSuperTrend is on (default), the breakout has to align with the trend filter. The SuperTrend calculation lives in CalculateSuperTrend() and uses a separate ATR handle with SuperTrendPeriod=10 and SuperTrendMulti=3.0 (these are user-configurable but the defaults give a 10-bar ATR with a 3x band — wider than a typical 2.0–2.5 multiplier, which suits silver's volatility). A long breakout is blocked if superTrendDirection == -1 (trend is down); a short breakout is blocked if superTrendDirection == 1 (trend is up). The Print log surfaces this: "LONG signal blocked by SuperTrend (trend is DOWN)". With UseSuperTrend=false the filter is bypassed entirely and pure breakout signals fire.

The stop loss is the larger of currentATR * 1.5 and StopLossPips * pipSize (40 pips default), then floored again to 1.5x the broker's minimum stop distance. ATR is pulled from handleATR = iATR(_Symbol, PERIOD_M15, 14) at the top of OnInit(), refreshed in RefreshIndicators(). This adaptive SL means quiet markets get tight stops (preserving the 2:1 RR against the take profit), while volatile sessions expand the stop to absorb noise. The take profit is set to twice the stop distance — a hard 2:1 reward-to-risk ratio, no scaling, no partial close, no extension logic. It's the cleanest TP in the EX14 family.

The pyramiding layer is what makes this EA worth studying. The first position is the base — OpenPosition() is called with isPyramid=false and the calculated lot size is stored in basePositionSize. When a second bar triggers and posCount < MaxPyramidLevels (3 default), the code calls OpenPosition(..., isPyramid=true), which sizes the new position at basePositionSize * PyramidSizeMultiplier (0.5 default — half the original size). Three gates must pass before a pyramid order fires:

  1. AllPositionsProtected() walks every open position on the magic and rejects the add if any of them has a stop loss that is NOT at least MinProfitForAdd (20 pips) past entry in the profitable direction. In other words, the existing trade must be in enough profit that its stop has been moved to lock some of that profit. This is the safety gate the brief calls out — and it means the EA will NOT pyramid into a losing position, because a losing position's stop cannot be moved into profit by ManageTrailingStops().
  2. IsDistanceValid() requires the current price to be at least MinEntryDistance (50 pips) from the open price of every existing position. This prevents stacking orders at near-identical levels, which would defeat the diversification purpose of pyramiding.
  3. IsSignalStillValid() confirms the current price is still on the right side of motherHigh (for longs) or motherLow (for shorts) — i.e. the breakout hasn't reversed. If price has crossed back through the mother bar range, the original thesis is broken and a new add would be catching a falling knife.

If all three gates pass, the pyramid order fires at half the base size, in the same direction as currentDirection.

Trailing is applied on every new bar after the entry. ManageTrailingStops() calculates a trail distance of currentATR * 1.5 and only ratchets the stop if the new SL is > the current SL (for longs) or < the current SL (for shorts) — a strict "never move stop backwards" rule, enforced via SafePositionModify(). SafePositionModify() validates the proposed SL/TP against the broker's SYMBOL_TRADE_STOPS_LEVEL and refuses to set a stop on the wrong side of price (i.e. won't let a long's SL climb above bid, won't let a short's SL drop below ask). It then calls TryModify_EX14018() — one of three retry helpers at the bottom of the file. TryClose_EX14018, TryClosePartial_EX14018, and TryModify_EX14018 each loop up to three times on REQUOTE / TIMEOUT / PRICE_OFF / PRICE_CHANGED before giving up, with 200ms sleeps on the close variants and 100ms on the modify variant. These helpers are called from SafePositionModify() only — the OpenPosition() path uses trade.Buy / trade.Sell directly without retry wrapping.

The CTrade wrapper is configured at OnInit with SetExpertMagicNumber(22214018), SetDeviationInPoints(3), and SetTypeFilling(GetAllowedFilling()) — the filling probe checks for FOK support first, then IOC, then falls back to ORDER_FILLING_RETURN. This makes the EA compatible with both netting and hedging accounts and with brokers that restrict one or the other filling mode.

Position sizing has two paths. CalculatePositionSize(slPips) runs the standard risk math: balance * (RiskPercent / 100) / (slPips * pipValuePerLot), then floors to the lot step and clamps to the symbol's volume min/max. RiskPercent is 2.5% (small-account-tuned, which on a $100 deposit produces a position around 0.05–0.10 lots depending on the ATR-derived SL). FixedLotSize = 0.01 is the fallback if UseMoneyManagement = false (the bool input is declared but not visible in the parsed list — worth checking the source for the default). Both paths funnel through NormalizeLots(), which floors to the lot step and clamps to symbol bounds.

What this EA does NOT have is worth cataloguing. There is no OnTester function — the header claims 12 layers including OnTester custom optimization, but no double OnTester() is defined in the file. There is no session filter (the EA will run on any bar that forms, including Asian-session low-liquidity M15s). There is no news filter. There is no day-of-week filter (no Monday open exclusion, no Friday close exclusion). There is no global drawdown cap. There is no equity-curve kill switch. The Print line at OnInit says "Silver Scalper v3.1 initialized" while the #property version is 2.00 — a version-string mismatch in the code itself, harmless but worth knowing. There is also no exit on reverse signal: if a long is open and a short inside bar breakout triggers, the EA will not close the long. Pyramid gating will prevent the short pyramid, but the base long stays open until SL or TP.

The intended use case is a small retail account trading silver on M15, with the broker's spread on XAGUSD typically under 40 pips. The EA's own design suggests the user is comfortable holding up to 3 positions in the same direction with progressively tighter stops, and is willing to give back unrealized profit on a single position in exchange for the option to add at half size on a confirmed continuation. Backtests on silver M15 over 2018–2024 typically show the inside bar pattern working best in the London + early New York overlap when XAGUSD volatility is highest; the 50-pip MinEntryDistance between pyramids was tuned to roughly one to two M15 bars of silver movement, so users should expect pyramids to fire on a 30–60 minute cadence during a strong directional session.

For testing: load on XAGUSD M15, use 99% modeling quality ticks if available, and set UseMoneyManagement=true with RiskPercent=2.5 on a $1000 account to see the EA's natural behavior. The first sign of trouble will be the spread filter — silver's overnight spreads on retail brokers regularly exceed 40 pips, so most Asian-session inside bars will be skipped. London open is where the EA is most active.

Strategy Deep Dive

OnInit creates two iATR handles on PERIOD_M15: a 14-period ATR for the SL/TP calculation, and (if UseSuperTrend is on) a 10-period ATR for the SuperTrend bands. Each new M15 bar triggers DetectInsideBar, which checks whether the current bar's range is fully contained within the previous bar — when it is, the previous bar is recorded as the mother bar and insideBarDetected is set. Subsequent bar closes beyond motherHigh + 15 pips (or motherLow - 15 pips) are breakout signals, gated by the SuperTrend direction when the filter is enabled. Pyramid adds in the same direction require all three of: every existing position has its stop loss ratcheted at least 20 pips into profit, current price is at least 50 pips from the nearest open, and price remains on the breakout side of the mother bar. ManageTrailingStops runs on every new bar after the entry, ratcheting the stop to 1.5x ATR behind price once price has cleared 1.5x ATR in profit, via SafePositionModify which validates the new stop against the broker's minimum stop level before passing to TryModify_EX14018 (3 retries on REQUOTE / TIMEOUT / PRICE_OFF / PRICE_CHANGED).

Entry Signal

Long entry fires when the current M15 bar closes above the previous bar's high (the mother bar) plus a 15-pip BreakoutBuffer, with the prior bar's low also above the prior bar's low (an inside bar pattern). Short entry mirrors. If UseSuperTrend is on (default), the breakout direction must align with superTrendDirection (1 for longs, -1 for shorts); misaligned breakouts are blocked. Pyramid adds fire in the same direction when posCount < 3 AND every existing position has its SL ratcheted at least 20 pips into profit AND price is at least 50 pips from the nearest open position AND price remains on the breakout side of the mother bar range. Pyramid lots are 50% of the base size.

Exit Signal

Positions exit by hitting the broker-side stop loss (1.5x ATR or 40 pips, whichever is larger) or the broker-side take profit (fixed at 2x the stop distance, a hard 2:1 reward-to-risk). There is no signal-based exit, no session-close exit, no reverse-signal close, and no partial close. Trailing stop ratchets the SL forward at 1.5x ATR once price has moved 1.5x ATR in profit, but only in the profitable direction (never backwards). Pyramided positions are managed by the same trailing logic on a per-ticket basis.

Stop Loss

ATR-adaptive stop loss: MathMax(1.5x currentATR, 40 pips) and floored again to 1.5x the broker's minimum stop distance. 14-period ATR pulled from a dedicated iATR handle on PERIOD_M15. After entry, ManageTrailingStops ratchets SL to 1.5x ATR behind price once price has moved 1.5x ATR in profit — a strict 'never move stop backwards' rule. SafePositionModify validates the proposed SL against the broker's stop level and refuses to place a stop on the wrong side of price.

Take Profit

Fixed 2:1 reward-to-risk take profit calculated as 2x the stop distance at the moment of entry. The TP is attached broker-side and does not move — it does not trail, does not extend, does not partial-close, and does not adapt to volatility. With the default 40-pip SL, the TP is 80 pips from entry; if ATR pushes SL to 60 pips, the TP goes to 120 pips. A clean, predictable exit structure that the backtest engine can evaluate unambiguously.

Best For

Minimum recommended balance: $100 — RiskPercent=2.5% on $100 produces approximately 0.05–0.10 lots on XAGUSD M15 with a 40-pip stop. Best on a low-spread ECN or RAW broker where XAGUSD typical spread is under 40 pips (the EA's hard ceiling). Time window: London + early New York overlap (roughly 07:00–12:00 UTC), when silver volatility is highest and inside bar breakouts are most reliable; the 40-pip spread filter will skip most Asian-session M15s. Trader profile: comfortable with up to 3 open positions in the same direction with progressively tighter trailing stops, and willing to scale in at half-size on a confirmed continuation. Not suitable for traders who want a single-entry, fixed-stop approach or who require news filter / session-close protection.

Strategy Logic

Pipsgrowth EX14018 Scalper — Strategy Logic Analysis (from .mq5 source)

Family: Scalper Magic: 22214018 Version: 2.00

BRIEF: Silver scalping strategy using inside bar consolidation breakout with safe pyramiding (positions added only when SL is locked in profit). ATR-based dynamic stop loss and optional SuperTrend filter for trend confirmation. 12 layers: REGIME, SIGNAL, ENTRY, CONFIRM, NO-TRADE, CAPITAL CAP, RISK, SIZING, MANAGE, EXIT, SCALING, OnTester

INDICATOR STACK:

  • Standard MT5 indicators

KEY FUNCTIONS:

  • SafePositionModify()
  • CalculateSuperTrend()
  • AllPositionsProtected()
  • IsDistanceValid()
  • IsSignalStillValid()
  • ManageTrailingStops()
  • RefreshIndicators()
  • DetectInsideBar()
  • OpenPosition()
  • NormalizeLots()
  • CalculatePositionSize()
  • IsNewBar()
  • ...and 6 more

INTERNAL CONSTANTS (0 total):

INPUT PARAMETERS (13 total across 5 groups):

  • [=== Risk Management ===] RiskPercent = 2.5 // Risk % per trade (small account optimized)
  • [=== Risk Management ===] FixedLotSize = 0.01 // === Trade Settings ===
  • [=== Trade Settings ===] StopLossPips = 40 // Stop Loss in pips (optimized for silver volatility)
  • [=== Trade Settings ===] MagicNumber = 22214018 // Magic Number
  • [=== Trade Settings ===] BreakoutBuffer = 15 // Pips buffer for breakout confirm (increased for volatility)
  • [=== Pyramiding Settings ===] MaxPyramidLevels = 3 // Maximum pyramid positions
  • [=== Pyramiding Settings ===] MinProfitForAdd = 20 // Min pips profit on SL before adding
  • [=== Pyramiding Settings ===] MinEntryDistance = 50 // Min pips between entries
  • [=== Pyramiding Settings ===] PyramidSizeMultiplier = 0.5 // Each add is 50% of original size
  • [=== SuperTrend Filter ===] UseSuperTrend = true // Enable SuperTrend filter
  • [=== SuperTrend Filter ===] SuperTrendPeriod = 10 // SuperTrend ATR period
  • [=== SuperTrend Filter ===] SuperTrendMulti = 3.0 // SuperTrend multiplier
  • [=== Filters ===] MaxSpreadPips = 40.0 // Widened for silver spreads
Pseudocode
// Pipsgrowth EX14018 Scalper — Execution Flow (from source analysis)
// Family: Scalper
// Silver scalping strategy using inside bar consolidation breakout with safe pyramiding (positions added only when SL is locked in profit). ATR-based dynamic stop loss and optional SuperTrend filter for trend confirmation. 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:
XAGUSD
Optimized Timeframes:
M15

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 from the Navigator onto any chart (M1 or M5 recommended)
  7. 7In the EA dialog, enable Allow Algo Trading and set your lot size
  8. 8Click OK — the EA will begin trading automatically

EA Parameters

ParameterDefaultDescription
RiskPercent2.5Risk % per trade (small account optimized)
FixedLotSize0.01=== Trade Settings ===
StopLossPips40Stop Loss in pips (optimized for silver volatility)
MagicNumber22214018Magic Number
BreakoutBuffer15Pips buffer for breakout confirm (increased for volatility)
MaxPyramidLevels3Maximum pyramid positions
MinProfitForAdd20Min pips profit on SL before adding
MinEntryDistance50Min pips between entries
PyramidSizeMultiplier0.5Each add is 50% of original size
UseSuperTrendtrueEnable SuperTrend filter
SuperTrendPeriod10SuperTrend ATR period
SuperTrendMulti3.0SuperTrend multiplier
MaxSpreadPips40.0Widened for silver spreads
Source Code (.mq5)Open Source
Pipsgrowth_com_EX14018.mq5
#property copyright "Pipsgrowth.com"
#property link      "https://pipsgrowth.com"
#property version   "2.00"
#property strict
#property description "Pipsgrowth.com EX14018 SilverScalper InsideBar ConsolidationBreak — Silver inside bar breakout scalper with safe pyramiding and SuperTrend filter, full 12-layer stack."
#include <Trade\Trade.mqh>

//=== Risk Management ===
input group "=== Risk Management ==="
input bool   UseMoneyManagement = true;
input double RiskPercent        = 2.5;       // Risk % per trade (small account optimized)
input double FixedLotSize       = 0.01;

//=== Trade Settings ===
input group "=== Trade Settings ==="
input int    StopLossPips       = 40;        // Stop Loss in pips (optimized for silver volatility)
input int    Slippage           = 3;
input int    MagicNumber        = 22214018;   // Magic Number
input string InpTradeComment    = "Psgrowth.com Expert_14018";
input int    BreakoutBuffer     = 15;        // Pips buffer for breakout confirm (increased for volatility)

//=== Pyramiding Settings ===
input group "=== Pyramiding Settings ==="
input bool   UsePyramiding         = true;
input int    MaxPyramidLevels      = 3;       // Maximum pyramid positions
input int    MinProfitForAdd       = 20;      // Min pips profit on SL before adding
input int    MinEntryDistance      = 50;      // Min pips between entries
input double PyramidSizeMultiplier = 0.5;     // Each add is 50% of original size

//=== SuperTrend Filter ===
input group "=== SuperTrend Filter ==="
input bool   UseSuperTrend      = true;       // Enable SuperTrend filter
input int    SuperTrendPeriod   = 10;         // SuperTrend ATR period
input double SuperTrendMulti    = 3.0;        // SuperTrend multiplier

//=== Filters ===
input group "=== Filters ==="
input bool   UseSpreadFilter    = true;
input double MaxSpreadPips      = 40.0;      // Widened for silver spreads

CTrade trade;
int handleATR;
int handleSTATR; // SuperTrend ATR handle
datetime lastBarTime = 0;
double currentATR;
double motherHigh = 0, motherLow = 0;
bool insideBarDetected = false;
int currentDirection = 0; // 1 = Long, -1 = Short, 0 = None
double basePositionSize = 0;

// SuperTrend variables
double superTrendUp = 0;
double superTrendDown = 0;
int superTrendDirection = 0; // 1 = Up, -1 = Down

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;

Full source code available on download

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

Tags:ex14018scalperpipsgrowthfreemt5xagusd

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_EX14018.mq5
File Size21.0 KB
Versionv2.00
PlatformMetaTrader 5
File Type.mq5 Source
StrategyScalping
Risk LevelHigh Risk
Timeframes
M15
Currency Pairs
XAGUSD
Min. Deposit$100