P
PipsGrowth
OtherOpen Source – Free

Pipsgrowth EX17007 Volatility

MT5 Expert Advisor (Open Source) · XAUUSD · M15, M5

Pipsgrowth.com EX17007 GoldScalper_ATRBurst_RangeBreakout — ATR burst range breakout gold scalper, full 12-layer stack.

Overview

EX17007 is a gold-focused volatility scalper that hunts for ATR expansion bursts on the M15 chart and converts them into Bollinger-band breakouts or pullback re-entries. The name says it plainly: the EA fires when the Average True Range (14) climbs above its 20-bar average by a configurable multiplier (1.3 by default), then looks for a directional trigger — typically a band pierce and an RSI(14) midline cross, or alternatively a Bollinger breakout and an EMA cross, or a pullback to the fast EMA inside an established EMA(9)/EMA(21) trend. Trades are not all-or-nothing; the EA runs three independent entry modes that can be toggled in any combination, and the highest-confidence mode gets first refusal on each new M15 bar.

The 3-mode priority chain

GetSignal() ranks the entry modes by confidence, not by speed. Mode 1 (ATR Burst, UseATRBurstEntry) demands all three conditions simultaneously: ATR > ATR_MA(20) * 1.3, the previous M15 bar closed outside the Bollinger band, and RSI(14) crossed the 50 midline in the trade direction. If any of those fail, the EA falls through to Mode 2 (Bollinger Breakout, UseBreakoutEntry), which requires a close beyond the band plus a 2-pip buffer and EMA(9) > EMA(21) alignment. If that also fails, Mode 3 (Pullback, UsePullbackEntry) waits for a bar to close back through the fast EMA inside an active EMA(9)/EMA(21) trend. This means the EA's behavior changes character based on which modes the trader enables — turning Mode 1 off leaves a slower, lower-frequency breakout EA; turning all three on produces the most trades, with the most redundancy.

The indicator stack

Five handles feed every decision. The ATR(14) reading is averaged over a 20-bar lookback to build the burst baseline. Bollinger Bands (20-period, 2.0 deviation, close) supply the breakout rails and the stretched condition. RSI(14) is read both on the current bar and on the previous bar to detect the 50-cross. EMA(9) and EMA(21) provide the trend filter. All five are attached to the M15 timeframe via OnInit() and torn down cleanly in OnDeinit(). The pip size helper GetPipSize() returns 10 * _Point on 3- and 5-digit brokers, _Point otherwise, which is what makes the pips-to-price conversions safe across gold's typical 2-decimal and 3-decimal quote modes.

Position sizing and risk

With UseMoneyManagement on (the default), every order sizes to 1.5% of the current balance. CalculatePositionSize() converts that into lots by dividing the risk amount (balance * 0.015) by the product of SL distance in pips and the per-pip value of one lot. The result is floored to the broker's volume step and clipped to the broker's lot limits. A margin check follows: if the calculated order would consume more than 90% of free margin, the size is scaled down proportionally. If UseMoneyManagement is off, the EA uses FixedLotSize = 0.01 regardless of SL distance, which is a useful diagnostic setting for backtests but not a production one.

Stop-loss and take-profit

SL is adaptive, anchored to current ATR: the distance is the maximum of (currentATR * 2.0), (StopLossPips * pipSize, default 15 pips), and (1.5 * broker stop-level). This means in low-volatility regimes the floor wins, in volatile regimes the ATR anchor wins, and in either case the SL respects the broker's minimum stop distance. TP is fixed at a 2:1 reward-to-risk ratio — exactly twice the SL distance from entry. There is no partial TP layer, no basket TP, and no time-decay exit in the source; the trailing stop is the only mechanism that adjusts an open position's exit.

Trailing stop

ManageOpenPositions() runs on every tick (before the new-bar gate), and once the position is in profit by more than TrailingStartPips (12 pips default), the stop is ratcheted to current_price -/+ TrailingStartPips. The ratchet only moves in the favorable direction and only when the move exceeds TrailingStepPips (5 pips) — a real movement, not point-size noise. SafePositionModify() validates every modification against the broker's minimum stop distance before sending it, and TryModify_EX17007() retries up to 3 times on requote or timeout with a 100ms sleep.

Pyramiding

The default behavior is to take one position at a time, but UsePyramiding can be flipped on. When enabled, CanOpenPosition() will allow up to MaxOpenPositions (3) entries in the same direction, each at least PyramidDistPips (20) away from the previous entry. The distance check is in pips, not in ATR, so a tight ATR regime can produce tightly stacked adds, while a wide ATR regime spreads them out naturally.

Filters and safety

Three pre-trade gates run on every new M15 bar. UseTimeFilter restricts entries to the server-time window between StartTime (08:00) and EndTime (17:00), which captures the London and early New York sessions — when gold sees its highest intraday range and cleanest breakouts. UseSpreadFilter rejects bars where the spread exceeds MaxSpreadPips (25 pips), which is calibrated for XAUUSD where typical spreads run 10-30. CheckDailyLimits() compares current equity against the equity at the start of the calendar day and disables new entries if the daily P/L is below -$30, but does not auto-close existing positions.

What to expect in backtest

The combination of three toggleable entry modes and a 2:1 fixed R:R means the EA's profile is highly dependent on which modes the user enables. ATR Burst-only produces the fewest, highest-conviction signals. Pullback-only is more active and trends better. All three on produces the highest trade count and the most duplicated exposure. Because the SL adapts to ATR, the per-trade risk in points will scale with market conditions; the 1.5% risk-percent setting keeps the dollar risk constant, but the per-pip exposure rises and falls with volatility. Run the Strategy Tester with "Every tick" or "Every tick based on real ticks" mode, not "Open prices only", because the trailing stop and order modifications depend on tick-by-tick price evolution.

Strategy Deep Dive

Five indicator handles — ATR(14), Bollinger Bands (20, 2.0, close), RSI(14), EMA(9), EMA(21) — are attached to the M15 chart in OnInit() and refreshed on each new bar. GetSignal() ranks three independent entry modes by confidence: an ATR-burst gate that requires current ATR > 1.3× its 20-bar mean plus a Bollinger-band pierce and an RSI(14) 50-cross; a Bollinger-breakout gate that needs a close beyond the band with EMA(9) > EMA(21) trend alignment; and a pullback gate that waits for a bar to close back through the EMA(9) inside an active trend. CalculatePositionSize() converts 1.5% balance risk into lots (falling back to 0.01 fixed when UseMoneyManagement is off) and applies a 90% free-margin cap. The 2:1 R:R TP and ATR-anchored SL are set at order open, then ManageOpenPositions() runs on every tick to ratchet the SL forward via SafePositionModify() once profit exceeds 12 pips, stepping every 5 pips. CheckDailyLimits() disables new entries if the day sits below -$30 of equity drawdown but does not force-close existing positions.

Entry Signal

EX17007 fires on any of three independent entry modes: an ATR(14) burst above 1.3× its 20-bar mean coinciding with a Bollinger-band pierce and RSI(14) cross of 50, a Bollinger-band breakout with EMA(9)>EMA(21) trend alignment, or a pullback to the EMA(9) inside an established EMA(9)/EMA(21) trend. Each mode can be toggled on or off independently; when all three are on, the highest-confidence mode (ATR burst) takes priority. Entries execute on the open of the M15 bar following the signal bar.

Exit Signal

There is no opposite-signal exit and no time-based close in EX17007; the EA relies entirely on the initial fixed TP and the trailing stop. ManageOpenPositions() ratchets the SL forward once profit exceeds TrailingStartPips (12 pips), then steps it every TrailingStepPips (5 pips) of additional price movement, and only in the favorable direction. The 2:1 R:R take-profit is set at order open and never modified.

Stop Loss

SL is adaptive and ATR-anchored: the stop distance is the maximum of (currentATR × 2.0), (StopLossPips × pipSize, default 15 pips), and 1.5× the broker's stop level. The same SL formula applies to all three entry modes; there is no global equity-stop or basket drawdown cap beyond the $30 daily P/L gate.

Take Profit

TP is a fixed 2:1 reward-to-risk ratio, set to exactly twice the SL distance from entry at order open. There is no partial TP, no basket TP, and no TP adjustment from the trailing logic — the EA leaves the original TP untouched unless the SL is ratcheted closer.

Best For

Minimum recommended balance is $100 (or its gold-equivalent), which the 1.5% risk setting translates to roughly $1.50 risk per trade at default config. The EA is built for XAUUSD on M15 (and works on M5); it targets the London and early New York session window from 08:00 to 17:00 server time, when gold produces its cleanest ATR bursts and band breakouts. Broker requirements: low-spread XAUUSD execution (the 25-pip spread filter is calibrated for typical retail gold spreads of 10-30 pips), hedging or netting account, and 0.01 lot step. Risk level is MEDIUM given the 1.5% per-trade risk and 2:1 R:R.

Strategy Logic

Pipsgrowth EX17007 Volatility — Strategy Logic Analysis (from .mq5 source)

Family: Volatility Magic: 22217007 Version: 2.00

BRIEF: Gold scalping strategy using ATR burst detection with range breakout confirmation. Enters on ATR expansion + price breakout + RSI cross, with tiered TP, trailing stop, time- based exit and dynamic position sizing. Full 12-layer stack. 12 layers: REGIME, SIGNAL, ENTRY, CONFIRM, NO-TRADE, CAPITAL CAP, RISK, SIZING, MANAGE, EXIT, SCALING, OnTester

INDICATOR STACK:

  • Standard MT5 indicators

KEY FUNCTIONS:

  • SafePositionModify()
  • RefreshIndicators()
  • GetSignal()
  • CanOpenPosition()
  • OpenPosition()
  • CalculatePositionSize()
  • ManageOpenPositions()
  • IsNewBar()
  • GetPipSize()
  • CheckDailyLimits()
  • CheckFilters()
  • TryClose_EX17007()
  • ...and 2 more

INTERNAL CONSTANTS (0 total):

INPUT PARAMETERS (31 total across 9 groups):

  • [=== Risk Management ===] UseMoneyManagement = true // Use Dynamic Risk %
  • [=== Risk Management ===] RiskPercent = 1.5 // Risk Percent per Trade
  • [=== Risk Management ===] FixedLotSize = 0.01 // Fixed Lot Size (if MM false)
  • [=== Risk Management ===] MaxDailyLossUSD = 30.0 // Max Daily Loss ($)
  • [=== ATR Settings ===] ATR_Period = 14 // ATR Period
  • [=== ATR Settings ===] ATR_MA_Period = 20 // ATR MA Period
  • [=== ATR Settings ===] ATRBurstMultiplier = 1.3 // ATR Spike Multiplier
  • [=== Entry Settings ===] UseATRBurstEntry = true // Use ATR Burst Entry
  • [=== Entry Settings ===] UseBreakoutEntry = true // Use Bollinger Breakout Entry
  • [=== Entry Settings ===] UsePullbackEntry = true // Use Pullback Entry
  • [=== Entry Settings ===] RSI_Period = 14 // RSI Period
  • [=== Bollinger Bands ===] BB_Period = 20 // Bollinger Period
  • [=== Bollinger Bands ===] BB_Deviation = 2.0 // Bollinger Deviation
  • [=== EMA Settings ===] FastEMA_Period = 9 // Fast EMA Period
  • [=== EMA Settings ===] SlowEMA_Period = 21 // Slow EMA Period
  • [=== Trade Settings ===] StopLossPips = 15 // Min Stop Loss (pips)
  • [=== Trade Settings ===] SL_ATR_Multiplier = 2.0 // SL ATR Multiplier
  • [=== Trade Settings ===] Slippage = 3 // Max Slippage (points)
  • [=== Trade Settings ===] InpMagicNumber = 22217007 // Magic Number (222 + Expert ID)
  • [=== Trade Settings ===] InpTradeComment = "Psgrowth.com Expert_17007" // Trade Comment
  • [=== Trailing Stop ===] UseTrailingStop = true // Use Trailing Stop
  • [=== Trailing Stop ===] TrailingStartPips = 12 // Trailing Start (pips)
  • [=== Trailing Stop ===] TrailingStepPips = 5 // Trailing Step (pips)
  • [=== Pyramiding ===] UsePyramiding = false // Use Pyramiding
  • [=== Pyramiding ===] MaxOpenPositions = 3 // Max Open Positions
  • [=== Pyramiding ===] PyramidDistPips = 20 // Distance between entries (pips)
  • [=== Filters ===] UseSpreadFilter = true // Use Spread Filter
  • [=== Filters ===] MaxSpreadPips = 25.0 // Max Spread (pips) - XAUUSD typically 10-30
  • [=== Filters ===] UseTimeFilter = true // Use Time Filter
  • [=== Filters ===] StartTime = "08:00" // Start Time (HH:MM)
  • [=== Filters ===] EndTime = "17:00" // End Time (HH:MM)
Pseudocode
// Pipsgrowth EX17007 Volatility — Execution Flow (from source analysis)
// Family: Volatility
// Gold scalping strategy using ATR burst detection with range breakout confirmation. Enters on ATR expansion + price breakout + RSI cross, with tiered TP, trailing stop, time- based exit and dynamic position sizing. Full 12-layer stack. 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:
XAUUSD
Optimized Timeframes:
M15M5

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 onto a chart matching the recommended timeframe
  7. 7Configure parameters according to the table on this page
  8. 8Enable Allow Algo Trading and click OK

EA Parameters

ParameterDefaultDescription
UseMoneyManagementtrueUse Dynamic Risk %
RiskPercent1.5Risk Percent per Trade
FixedLotSize0.01Fixed Lot Size (if MM false)
MaxDailyLossUSD30.0Max Daily Loss ($)
ATR_Period14ATR Period
ATR_MA_Period20ATR MA Period
ATRBurstMultiplier1.3ATR Spike Multiplier
UseATRBurstEntrytrueUse ATR Burst Entry
UseBreakoutEntrytrueUse Bollinger Breakout Entry
UsePullbackEntrytrueUse Pullback Entry
RSI_Period14RSI Period
BB_Period20Bollinger Period
BB_Deviation2.0Bollinger Deviation
FastEMA_Period9Fast EMA Period
SlowEMA_Period21Slow EMA Period
StopLossPips15Min Stop Loss (pips)
SL_ATR_Multiplier2.0SL ATR Multiplier
Slippage3Max Slippage (points)
InpMagicNumber22217007Magic Number (222 + Expert ID)
InpTradeComment"Psgrowth.com Expert_17007"Trade Comment
UseTrailingStoptrueUse Trailing Stop
TrailingStartPips12Trailing Start (pips)
TrailingStepPips5Trailing Step (pips)
UsePyramidingfalseUse Pyramiding
MaxOpenPositions3Max Open Positions
PyramidDistPips20Distance between entries (pips)
UseSpreadFiltertrueUse Spread Filter
MaxSpreadPips25.0Max Spread (pips) - XAUUSD typically 10-30
UseTimeFiltertrueUse Time Filter
StartTime"08:00"Start Time (HH:MM)
EndTime"17:00"End Time (HH:MM)
Source Code (.mq5)Open Source
Pipsgrowth_com_EX17007.mq5
#property copyright "Pipsgrowth.com"
#property link      "https://pipsgrowth.com"
#property version   "2.00"
#property strict
#property description "Pipsgrowth.com EX17007 GoldScalper_ATRBurst_RangeBreakout — ATR burst range breakout gold scalper, full 12-layer stack."

#include <Trade\Trade.mqh>

//+------------------------------------------------------------------+
//| Inputs                                                           |
//+------------------------------------------------------------------+
input group "=== Risk Management ==="
input bool   UseMoneyManagement = true;       // Use Dynamic Risk %
input double RiskPercent        = 1.5;        // Risk Percent per Trade
input double FixedLotSize       = 0.01;       // Fixed Lot Size (if MM false)
input double MaxDailyLossUSD    = 30.0;       // Max Daily Loss ($)

input group "=== ATR Settings ==="
input int    ATR_Period         = 14;         // ATR Period
input int    ATR_MA_Period      = 20;         // ATR MA Period
input double ATRBurstMultiplier = 1.3;        // ATR Spike Multiplier

input group "=== Entry Settings ==="
input bool   UseATRBurstEntry   = true;       // Use ATR Burst Entry
input bool   UseBreakoutEntry   = true;       // Use Bollinger Breakout Entry
input bool   UsePullbackEntry   = true;       // Use Pullback Entry
input int    RSI_Period         = 14;         // RSI Period

input group "=== Bollinger Bands ==="
input int    BB_Period          = 20;         // Bollinger Period
input double BB_Deviation       = 2.0;        // Bollinger Deviation

input group "=== EMA Settings ==="
input int    FastEMA_Period     = 9;          // Fast EMA Period
input int    SlowEMA_Period     = 21;         // Slow EMA Period

input group "=== Trade Settings ==="
input int    StopLossPips       = 15;         // Min Stop Loss (pips)
input double SL_ATR_Multiplier  = 2.0;        // SL ATR Multiplier
input int    Slippage           = 3;          // Max Slippage (points)
input int    InpMagicNumber     = 22217007;                      // Magic Number (222 + Expert ID)
input string InpTradeComment    = "Psgrowth.com Expert_17007"; // Trade Comment

input group "=== Trailing Stop ==="
input bool   UseTrailingStop    = true;       // Use Trailing Stop
input int    TrailingStartPips  = 12;         // Trailing Start (pips)
input int    TrailingStepPips   = 5;          // Trailing Step (pips)

input group "=== Pyramiding ==="
input bool   UsePyramiding      = false;      // Use Pyramiding
input int    MaxOpenPositions   = 3;          // Max Open Positions
input int    PyramidDistPips    = 20;         // Distance between entries (pips)

input group "=== Filters ==="
input bool   UseSpreadFilter    = true;       // Use Spread Filter
input double MaxSpreadPips      = 25.0;       // Max Spread (pips) - XAUUSD typically 10-30
input bool   UseTimeFilter      = true;       // Use Time Filter
input string StartTime          = "08:00";    // Start Time (HH:MM)
input string EndTime            = "17:00";    // End Time (HH:MM)

Full source code available on download

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

Tags:ex17007volatilitypipsgrowthfreemt5xauusd

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_EX17007.mq5
File Size22.8 KB
Versionv2.00
PlatformMetaTrader 5
File Type.mq5 Source
StrategyOther
Risk LevelMedium Risk
Timeframes
M15M5
Currency Pairs
XAUUSD
Min. Deposit$100