Pipsgrowth EX16007 Trend
MT5 Expert Advisor (Open Source) · XAUUSD · M15
Pipsgrowth.com EX16007 GoldScalper SuppResBounce ZoneRecovery — S/R bounce scalper, full 12-layer stack.
Overview
Pipsgrowth EX16007 is an XAUUSD M15 scalper that trades bounces off geometrically calculated support and resistance levels. Instead of relying on oscillators or moving averages for direction, the EA builds its zones from raw price action: it walks the previous 50 M15 bars, finds the highest high and the lowest low, and counts how many subsequent bar highs cluster within 10 pips of that peak (and how many lows cluster within 10 pips of the trough). A level only becomes a tradeable zone once the cluster hits 2 or more touches; that minimum confirmation input is what prevents every minor swing from being treated as a level. The confirmed resistance and support are stored as module-level doubles and refreshed at the start of every new M15 bar.
The entry logic sits in GetSRSignal(). On every new bar, the EA reads the close of bar 1 and the close of bar 2. A long signal fires when the confirmed support level is non-zero AND the distance between bar 1's close and the support level is less than 10 pips (the zone tolerance) AND bar 1 closed above bar 2 — a simple bounce condition that requires a real bullish reversal candle, not just a tag of the line. A short signal mirrors the condition against the resistance level. There is no ADX filter, no RSI filter, no trend bias — the signal is purely the geometric proximity test plus the close-over-close bounce check, which keeps the EA responsive but also means it depends on clean, well-formed S/R clusters to be selective.
Stop placement in OpenPosition() is anchored to the S/R level that triggered the trade, not to a fixed pip distance from entry. For a buy, the EA computes slPrice = supportLevel - 15 * pipSize — placing the stop 15 pips below the support zone, so a clean break of support kills the trade. For a sell, the stop sits 15 pips above resistance. The code then enforces a broker-safe minimum by taking max(slDist, minDist * 1.5) where minDist is derived from SYMBOL_TRADE_STOPS_LEVEL. If the calculated distance is below that floor, the SL is pushed out to comply — this is the same defensive padding pattern that shows up across the EX16 family.
Take-profit targets the opposite S/R level. A buy's TP is set to the resistance level, and a sell's TP is set to the support level. If the opposite level is too close to the current price (under minDist * 1.5), the EA falls back to a 2:1 reward-to-risk: tpPrice = price +/- slDist * 2. This produces a 1:2 RR by default and a variable TP when the channel is wide enough to support it. Both SL and TP are attached broker-side at order entry and never modified afterwards.
The risk and money-management layer uses the CalculatePositionSize() formula: lots = (balance * RiskPercent/100) / (slPips * pipValuePerLot). The pip-value per lot is derived from SYMBOL_TRADE_TICK_VALUE / SYMBOL_TRADE_TICK_SIZE * pipSize (where pipSize returns _Point * 10 for 3- and 5-digit symbols, raw _Point otherwise — the same XAUUSD-aware adjustment as the rest of the family). Lots are floored to SYMBOL_VOLUME_STEP, clamped between SYMBOL_VOLUME_MIN and SYMBOL_VOLUME_MAX. With the defaults of RiskPercent = 2.0 and a 15-pip SL on XAUUSD, a $1,000 account risks $20 per trade. A FixedLotSize = 0.01 fallback engages when UseMoneyManagement is toggled off.
The execution stack is intentionally tight. OnTick() is gated by IsNewBar() on M15 — only one decision pass per new bar. RefreshIndicators() copies the latest iATR(PERIOD_M15, 14) value, used as the per-trade volatility context for spread-to-ATR sanity checks even though ATR is not used in the SL formula. CheckFilters() enforces a 25-pip maximum spread when UseSpreadFilter = true. CountPositions() >= 1 blocks any new entry while a position is still open, enforcing strict single-position discipline per symbol and per magic 22216007. The single-position rule means the EA never pyramids, never grids, never averages — it is a clean one-trade-at-a-time bounce model.
Management is minimalist. The EA defines a SafePositionModify() helper that validates new SL/TP distances against SYMBOL_TRADE_STOPS_LEVEL, normalizes to _Digits, refuses to set the SL on the wrong side of price, and refuses to set the TP on the wrong side. But nothing in the live path actually invokes it after entry: there is no break-even step, no trailing stop, no partial close, no time-based exit, no reverse-signal exit. Positions close only on SL or TP hit, which is what makes the SL/TP geometry critical — get the zone wrong and there is no management to salvage the trade. OnDeinit() releases the ATR handle.
The order-execution resilience layer uses three retry helpers — TryClose_EX16007, TryClosePartial_EX16007, and TryModify_EX16007 — each attempting up to 3 calls on REQUOTE / TIMEOUT / PRICE_OFF / PRICE_CHANGED, with 200ms sleeps for close/partial and 100ms for modify between attempts. The helpers are wired into SafePositionModify() and exposed for any external caller, but since the EA never actually modifies positions post-entry, the only live path that benefits from this resilience is the one-time TP/SL attachment at order entry through trade.Buy() / trade.Sell(). Filling mode is auto-probed via GetAllowedFilling() (FOK preferred, then IOC, then RETURN), and trade.SetDeviationInPoints(Slippage=3) caps the slippage on market orders.
The five input groups — Risk Management, S/R Settings, Trade Settings, and Filters — keep configuration compact. Tweakable parameters are LookbackBars = 50 (how far back the EA scans for swing extremes), ZonePips = 10 (cluster tolerance), TouchConfirm = 2 (minimum touches to validate a level), StopLossPips = 15 (SL buffer beyond the S/R level), RiskPercent = 2.0 / FixedLotSize = 0.01 (sizing toggle), and MaxSpreadPips = 25.0 (entry filter). The magic number 22216007 and trade comment Psgrowth.com Expert_16007 identify the EA's orders on the account history.
What a backtest shows: the EA fires only on bars that close inside the 10-pip zone of a confirmed S/R level, which in trending markets may be a handful of trades per week, while in range-bound XAUUSD M15 sessions it can produce one or two signals per day. The lack of any break-even, trailing, or partial-close means every trade is a binary SL-or-TP outcome: 15-pip risk on the side of the broken level, 2:1 reward toward the opposite level (or to whichever S/R boundary the geometry exposes). Because the SL is placed beyond the S/R level, false breakouts that pierce the zone by 5-10 pips will still be stopped out — the EA does not try to ride a re-entry after a wick, it accepts the loss and waits for the next confirmed bounce. The strategy suits traders who already think in S/R channels and want the EA to mechanically detect and execute the bounces, rather than traders who expect adaptive trade management.
Strategy Deep Dive
Every new M15 bar, OnTick() calls RefreshIndicators() to copy the latest iATR(PERIOD_M15, 14), then CalculateSRLevels() walks bars 1-50, tracking the highest high and lowest low, and increments a touch counter when each bar's high/low falls within 10 pips of the running extreme — a level only confirms when its touch count crosses TouchConfirm = 2. GetSRSignal() then reads bar[1] close and bar[2] close: a long fires if the close sits inside the support zone AND closes above bar[2] (clean bounce), shorts mirror against resistance. CheckFilters() enforces a 25-pip maximum spread when UseSpreadFilter is on, and CountPositions() >= 1 blocks new entries while any position is still open, enforcing strict single-position discipline. OpenPosition() anchors the stop 15 pips beyond the S/R level that triggered the trade and points the TP at the opposite S/R level (with a 2:1 RR fallback). All three retry helpers (TryClose_EX16007, TryClosePartial_EX16007, TryModify_EX16007) attempt up to 3 calls on REQUOTE/TIMEOUT/PRICE_OFF/PRICE_CHANGED with 100-200ms sleeps; filling mode is auto-probed (FOK > IOC > RETURN) and Slippage = 3 caps market-order slippage.
Trades bounces off geometrically-calculated support and resistance. On every new M15 bar, the EA scans the previous 50 bars, identifies the highest high (resistance) and lowest low (support) where at least 2 bar highs/lows cluster within a 10-pip zone. A long signal fires when bar[1] closes within 10 pips of the confirmed support level AND closes above bar[2] (bullish reversal candle). A short signal mirrors the condition against resistance.
Positions exit only via the broker-side SL or TP. There is no trailing stop, no break-even step, no partial close, no time-based exit, and no reverse-signal close. The Take-profit targets the opposite S/R level (resistance for longs, support for shorts), or falls back to 2x SL distance if the opposite level is too close to the entry price.
For a buy, SL = supportLevel - 15 pips (placed 15 pips below the support zone). For a sell, SL = resistanceLevel + 15 pips. The code enforces a broker-safe minimum via max(slDist, minDist * 1.5) where minDist is derived from SYMBOL_TRADE_STOPS_LEVEL. SL is attached at order entry and never modified.
TP targets the opposite S/R level (resistance for buys, support for sells). If the opposite level is closer than minDist * 1.5 to the current price, TP falls back to 2x SL distance (a 1:2 RR). TP is attached at order entry and never modified.
XAUUSD M15 gold traders running a $100+ account on an ECN/RAW low-spread broker (max spread ≤25 pips). Suits traders who already think in geometric S/R channels and want the EA to mechanically detect and execute zone bounces with a clean single-position discipline. Best deployed during the London and London-NY overlap sessions when XAUUSD is most range-active on M15. Risk level: MEDIUM at the default 2% risk-per-trade.
Strategy Logic
Pipsgrowth EX16007 Trend — Strategy Logic Analysis (from .mq5 source)
Family: Trend
Magic: 22216007
Version: 2.00
BRIEF:
Gold Scalping EA trading bounces off calculated support/resistance zones. Detects S/R levels from recent price action and enters on bounces with ATR-based stops. 12 layers: REGIME, SIGNAL, ENTRY, CONFIRM, NO-TRADE, CAPITAL CAP, RISK, SIZING, MANAGE, EXIT, SCALING, OnTester
INDICATOR STACK:
- Standard
MT5indicators
KEY FUNCTIONS:
SafePositionModify()CalculateSRLevels()RefreshIndicators()GetSRSignal()OpenPosition()CalculatePositionSize()IsNewBar()GetPipSize()CheckFilters()CountPositions()TryClose_EX16007()TryClosePartial_EX16007()- ...and 1 more
INTERNAL CONSTANTS (0 total):
INPUT PARAMETERS (5 total across 2 groups):
- [=== S/R Settings ===]
LookbackBars= 50 // Bars to find S/R - [=== S/R Settings ===]
ZonePips= 10 // Zone tolerance in pips - [=== S/R Settings ===]
TouchConfirm= 2 // Min touches to confirm zone - [=== Trade Settings ===]
InpMagicNumber=22216007// MagicNumber(222 + Expert ID) - [=== Trade Settings ===]
InpTradeComment= "Psgrowth.com Expert_16007" // TradeComment
// Pipsgrowth EX16007 Trend — Execution Flow (from source analysis)
// Family: Trend
// Gold Scalping EA trading bounces off calculated support/resistance zones. Detects S/R levels from recent price action and enters on bounces with ATR-based stops. 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 |
|---|---|---|
| LookbackBars | 50 | Bars to find S/R |
| ZonePips | 10 | Zone tolerance in pips |
| TouchConfirm | 2 | Min touches to confirm zone |
| InpMagicNumber | 22216007 | Magic Number (222 + Expert ID) |
| InpTradeComment | "Psgrowth.com Expert_16007" | Trade Comment |
#property copyright "Pipsgrowth.com"
#property link "https://pipsgrowth.com"
#property version "2.00"
#property strict
#property description "Pipsgrowth.com EX16007 GoldScalper SuppResBounce ZoneRecovery — S/R bounce scalper, full 12-layer stack."
#include <Trade\Trade.mqh>
input group "=== Risk Management ==="
input bool UseMoneyManagement = true;
input double RiskPercent = 2.0;
input double FixedLotSize = 0.01;
input group "=== S/R Settings ==="
input int LookbackBars = 50; // Bars to find S/R
input int ZonePips = 10; // Zone tolerance in pips
input int TouchConfirm = 2; // Min touches to confirm zone
input group "=== Trade Settings ==="
input int StopLossPips = 15;
input int Slippage = 3;
input int InpMagicNumber = 22216007; // Magic Number (222 + Expert ID)
input string InpTradeComment = "Psgrowth.com Expert_16007"; // Trade Comment
input group "=== Filters ==="
input bool UseSpreadFilter = true;
input double MaxSpreadPips = 25.0;
CTrade trade;
int handleATR;
datetime lastBarTime = 0;
double currentATR;
double resistanceLevel = 0, supportLevel = 0;
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;
else return ORDER_FILLING_RETURN;
}
//+------------------------------------------------------------------+
//| Safe Position Modify - validates stops before modifying |
//+------------------------------------------------------------------+
bool SafePositionModify(ulong ticket, double newSL, double newTP)
{
// Select the position
if(!PositionSelectByTicket(ticket))
{
return false; // Position doesn't exist, no error needed
}
// Get current price
long type = PositionGetInteger(POSITION_TYPE);
double price = (type == POSITION_TYPE_BUY) ?
SymbolInfoDouble(_Symbol, SYMBOL_BID) :
SymbolInfoDouble(_Symbol, SYMBOL_ASK);
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.