Pipsgrowth EX18020 TrendFollow
MT5 Expert Advisor (Open Source) · USDJPY · M5, M1, M15
Pipsgrowth.com EX18020 USDJPY_Ultra_Aggressive_Martingale_EA — RSI+MACD scalper (martingale stripped, fixed-fractional), full 12-layer stack.
Overview
EX18020 ships as a surgically repaired version of an earlier USDJPY scalp strategy. The original v1.00 system leaned on martingale lot-doubling, a recovery take-profit, and a 20-pip grid that stacked losing positions until price reversed. In v2.00 every one of those mechanisms has been removed at the source level. There is no lot multiplier between trades. There is no recovery TP that averages into a position. There is no grid backup. The result is a single-position, fixed-fractional scalper where each entry stands or falls on its own, sized to risk 0.5 percent of effective capital per trade.
The signal engine is built on a deliberately loose RSI plus MACD confluence. The OnTick handler reads the last closed bar only — never the still-forming bar — and runs the CoreSignal function on RSI(7) and MACD(8, 17, 9). The RSI arm fires long when the closed-bar RSI prints below 35 (InpRSIOversold) or short when it prints above 65 (InpRSIOverbought). The MACD arm fires long when the MACD main line crosses above the signal line on bar[1] after being equal-or-below on bar[2], and short on the mirror cross. Either arm is sufficient to produce a direction; the function returns a confidence score between zero and one hundred derived from whichever arm was stronger.
Confirmation runs in the ConfirmEntry gate. The EA pulls the H1 EMA(50) value via the g_hHTFEMA handle and demands that the closed-bar close be on the trend-correct side: a long signal requires close above the H1 EMA(50), a short signal requires close below. Spread must be at or below 35 points (InpMaxSpreadPts), and the current hour must fall inside the SESSION_START_HOUR to SESSION_END_HOUR window — 6 to 21 server time. Anything outside those checks is rejected with a labelled reason printed to the Experts log.
The regime classifier is a seven-state machine driven by ADX(14), ATR(14) percentile, and Bollinger Band width. StrongTrend is the top tier with ADX at or above 30. WeakTrend covers ADX between the InpADXMin threshold (20) and 30. Expand fires when the current ATR sits above the 70th percentile of the 60-bar lookback AND the current Bollinger width exceeds the previous bar's width by 1.15 times. Compress fires when the ATR percentile is below 25. Breakout fires when the band width collapses below 0.0015 and ADX is rising. Range and Choppy catch the rest. Choppy is the only state hard-blocked by NoTradeBlock; the others are allowed through to the entry path.
Risk management is layered. The NoTradeBlock function checks capital-cap floor, daily loss limit of 3 percent, max open trades (1), cooldown after three consecutive losses, big-candle skip when a single bar's range exceeds three ATRs, and a Friday-21 server-time weekend cut-off. The position size is computed in CalcLots by dividing the risk money (0.5 percent of effective capital) by the per-lot loss implied by the 1.5 ATR stop distance, then rounded down to the broker's volume step.
Once a position is open the ManageExits function runs on every tick. It does four things in order. First, when unrealized R reaches +1.0, it moves the stop to break-even exactly at the entry price — a one-shot modification that fires only once per ticket. Second, it closes 50 percent of the position at +1R using the partial-TP machinery, also one-shot. Third, it ratchets the stop behind price using an ATR trail of 2.0 times the ATR, only ever tightening, never loosening. Fourth, if the position has been open for 100 bars or more on the current timeframe (MAX_BARS_IN_TRADE), it force-closes the position regardless of P&L.
The exit-side checks run in OppositeAndRegimeExit. If the closed-bar RSI crosses back through the opposite threshold or the MACD prints the mirror cross, every position is closed. The same function also force-closes positions when the regime classifier returns Choppy, Range, or Compress — meaning a position entered under a trending regime will be abandoned if the market flips into a non-trending state.
Under the hood the EA carries six indicator handles: ADX(14), ATR(14), RSI(7), MACD(8, 17, 9), Bollinger Bands(20, 2.0), and the HTF EMA(50) on H1. The OnTradeTransaction hook tracks consecutive losses and arms a three-bar cooldown when the count hits COOLDOWN_AFTER_LOSS — every loss counts the same, no escalation, no lot increase. The TryEntry, TryClose_EX18020, TryClosePartial_EX18020, and TryModify_EX18020 helpers all retry up to three times on requote, timeout, price-off, or price-changed responses with a 200-millisecond pause between attempts. The dry-run flag (InpDryRun, default true) suppresses every real send so you can audit the decision log before going live.
The OnTester custom criterion is (net × profit factor) ÷ (1 + absolute drawdown), with a hard floor of 30 closed trades in the optimization pass. Anything below 30 trades returns a zero score, which makes the optimizer discard short, low-sample runs in favour of statistically meaningful results.
What EX18020 is not: it is not a martingale, not a grid, not a recovery system. The v2.00 release pinned that down explicitly in both the header block and the entry path. If you came looking for a 20-pip grid stacker, this is no longer that EA. If you came looking for a tight, one-position-at-a-time RSI/MACD scalp with ATR-based exits and capital-cap sizing, this is the rebuilt version.
Strategy Deep Dive
On every tick the EA first runs the ManageExits housekeeping on any open position: ratchet the stop, take the +1R partial, push to break-even, and check the 100-bar time-out. On a new bar the closed-bar RSI(7) and MACD(8, 17, 9) values feed the CoreSignal function, which returns a signed direction with a 0-100 confidence score. ConfirmEntry then validates the H1 EMA(50) side, the 35-point spread cap, and the 6-21 server-time session. NoTradeBlock runs the safety stack — capital floor, daily 3 percent loss, three-loss cooldown, big-candle skip at 3x ATR, Friday-21 weekend cut-off, and the Choppy-regime hard block — and either releases the order to TryEntry or prints the labelled rejection. TryEntry sizes the lot from CalcLots using the 0.5 percent risk budget, sends the order with a one-retry fallback, and logs the decision in the Experts tab. The v2.00 build removed every martingale, recovery, and grid code path, so every order is sized independently off effective capital.
Entries fire on closed-bar signals only: a long triggers when RSI(7) prints below 35 OR MACD(8, 17, 9) main line crosses above the signal line, and a short triggers on the mirror conditions. The H1 EMA(50) gate then confirms by requiring the closed-bar close to sit on the trend-correct side, and the EA only arms orders inside the 6-21 server-time window with spread at or below 35 points. The seven-state regime classifier must not return Choppy for an entry to pass.
Exits run on every tick. The opposite-signal engine closes the position when the closed bar flips through the opposite RSI threshold or the MACD prints the mirror cross. The regime-change engine force-closes any open position the moment the classifier returns Choppy, Range, or Compress. A 100-bar time-out on the current timeframe force-closes the position regardless of P&L.
Per-trade stop is 1.5 times the ATR(14) value on the closed bar, floored by the broker's minimum stop distance. The EA moves the stop to break-even at +1R exactly once per ticket, then ratchets behind price using a 2.0x ATR trail that only tightens, never loosens. There is no recovery stop, no grid stop, no martingale step — every loss closes at the original ATR distance.
Initial take-profit is 1.5 times the stop distance, giving a fixed 1:1.5 R:R. At +1R the EA closes 50 percent of the position as a one-shot partial, then lets the remainder run toward either the original TP, the trail, the opposite-signal exit, the regime-change exit, or the 100-bar time cap, whichever hits first.
Minimum recommended balance is $100 with the CapitalCapAmount left at zero so the EA sizes off full equity. The CapitalCapFloor of 50 dollars acts as a hard circuit-breaker — if equity falls below it, the EA stops opening new orders. The strategy wants a low-spread ECN or RAW account on USDJPY because the 35-point spread cap is tight, and it should run on M5 (the default) with M1 and M15 as configurable fallbacks. The 6-21 server-time session targets the full London-through-New-York overlap, with the Friday 21:00 cutoff and the three-loss cooldown giving the EA room to breathe after drawdowns. The 0.5 percent risk and 3 percent daily loss cap make this a MEDIUM-risk position-at-a-time scalper, not an aggressive one.
Strategy Logic
Pipsgrowth EX18020 TrendFollow — Strategy Logic Analysis (from .mq5 source)
Family: TrendFollow
Magic: 22218020
Version: 2.00
BRIEF:
Ultra-aggressive USDJPY scalper. Entry signal = loose RSI(7) ±35/65 OR MACD(8/17/9) main/signal cross on closed bar, plus a quick-scalp trigger (MACD sign + RSI 50-side). v2.00 safety conversion: martingale COMPLETELY STRIPPED (no lot doubling, no recovery TP, no grid backup). Replaced with fixed- fractional sizing off effective capital. Hard ATR SL, R-multiple TP, every loss independent. Layered with REGIME, CONFIRM, NO- TRADE, CAPITAL-CAP, RISK, SIZING, MANAGE/EXIT, EXEC, OnTester. 12 layers: REGIME, SIGNAL, ENTRY, CONFIRM, NO-TRADE, CAPITAL CAP, RISK, SIZING, MANAGE, EXIT, SCALING, OnTester
INDICATOR STACK:
ADXATRRSIMACDBBHTFEMA
KEY FUNCTIONS:
NormPrice()ClampVol()MinStopsDist()SpreadPoints()InSession()IsNewBar()PartialAlreadyDone()MarkPartialDone()EffectiveCapital()RealizedPnLToday()CoreSignal()ConfirmEntry()- ...and 12 more
INTERNAL CONSTANTS (1 total):
ATR_PERIOD= 14 // ===================GLOBALS/HANDLES==============================
INPUT PARAMETERS (22 total across 6 groups):
- [=== General ===]
InpMagic=22218020// Magic number (id) - [=== General ===]
InpTradeComment= "Psgrowth.com Expert_18020" // Trade comment - [=== General ===]
InpDryRun=true// Dry-run: no real sends - [=== General ===]
InpKillSwitch=false// Kill switch (closes all on tick) - [=== General ===]
InpMaxSpreadPts=35.0// Max spread (points) - [=== Signal:
RSI+MACDScalp Confluence ===]InpRSIPeriod= 7 //RSIperiod (bars) - [=== Signal:
RSI+MACDScalp Confluence ===]InpRSIOversold=35.0//RSIoversold threshold - [=== Signal:
RSI+MACDScalp Confluence ===]InpRSIOverbought=65.0//RSIoverbought threshold - [=== Signal:
RSI+MACDScalp Confluence ===]InpMACDFast= 8 //MACDfastEMA(bars) - [=== Signal:
RSI+MACDScalp Confluence ===]InpMACDSlow= 17 //MACDslowEMA(bars) - [=== Signal:
RSI+MACDScalp Confluence ===]InpMACDSignal= 9 //MACDsignalEMA(bars) - [=== Regime ===]
InpADXMin=20.0// MinADXfor trend regime - [=== Regime ===]
InpATRPctLookback= 60 //ATRpercentile lookback (bars) - [=== Confirm &
HTF===]InpHTF= 8 //Timeframe(1=M1,2=M5,3=M15,4=M30,5=H1,6=H4,7=D1) //HTFtrend time-frame - [=== Confirm &
HTF===]InpHTFEMA= 50 //HTFEMAperiod (bars) - [=== Risk &
Sizing(Capital Allocation Cap) ===]InpCapitalCapAmount=0.0// Capital cap amount ($ equity) - [=== Risk &
Sizing(Capital Allocation Cap) ===]InpCapitalCapFloor=50.0// Capital cap floor ($) - [=== Risk &
Sizing(Capital Allocation Cap) ===]InpRiskPercent=0.5// Risk per trade (% of eff cap) [NO martingale] - [=== Risk &
Sizing(Capital Allocation Cap) ===]InpDailyLossPct=3.0// Daily loss limit (% eff cap) - [=== Exit / Manage ===]
InpATRSLMult=1.5// SL distance (xATR) - [=== Exit / Manage ===]
InpRRTP=1.5// TP distance (x SL distance) - [=== Exit / Manage ===]
InpATRTrailMult=2.0// In-tradeATRtrail (xATR)
// Pipsgrowth EX18020 TrendFollow — Execution Flow (from source analysis)
// Family: TrendFollow
// Ultra-aggressive USDJPY scalper. Entry signal = loose RSI(7) ±35/65 OR MACD(8/17/9) main/signal cross on closed bar, plus a quick-scalp trigger (MACD sign + RSI 50-side). v2.00 safety conversion: martingale COMPLETELY STRIPPED (no lot doubling, no recovery TP, no grid backup). Replaced with fixed- fractional sizing off effective capital. Hard ATR SL, R-multiple TP, every loss independent. Layered with REGIME, CONFIRM, NO- TRADE, CAPITAL-CAP, RISK, SIZING, MANAGE/EXIT, EXEC, OnTester. 12 layers: REGIME, SIGNAL, ENTRY, CONFIRM, NO-TRADE, CAPITAL CAP, RISK, SIZING, MANAGE, EXIT, SCALING, OnTester
ON_INIT:
Create indicator handles: ADX, ATR, RSI, MACD, BB, HTFEMA
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 |
|---|---|---|
| InpMagic | 22218020 | Magic number (id) |
| InpTradeComment | "Psgrowth.com Expert_18020" | Trade comment |
| InpDryRun | true | Dry-run: no real sends |
| InpKillSwitch | false | Kill switch (closes all on tick) |
| InpMaxSpreadPts | 35.0 | Max spread (points) |
| InpRSIPeriod | 7 | RSI period (bars) |
| InpRSIOversold | 35.0 | RSI oversold threshold |
| InpRSIOverbought | 65.0 | RSI overbought threshold |
| InpMACDFast | 8 | MACD fast EMA (bars) |
| InpMACDSlow | 17 | MACD slow EMA (bars) |
| InpMACDSignal | 9 | MACD signal EMA (bars) |
| InpADXMin | 20.0 | Min ADX for trend regime |
| InpATRPctLookback | 60 | ATR percentile lookback (bars) |
| InpHTF | 8 | Timeframe (1=M1,2=M5,3=M15,4=M30,5=H1,6=H4,7=D1) // HTF trend time-frame |
| InpHTFEMA | 50 | HTF EMA period (bars) |
| InpCapitalCapAmount | 0.0 | Capital cap amount ($ equity) |
| InpCapitalCapFloor | 50.0 | Capital cap floor ($) |
| InpRiskPercent | 0.5 | Risk per trade (% of eff cap) [NO martingale] |
| InpDailyLossPct | 3.0 | Daily loss limit (% eff cap) |
| InpATRSLMult | 1.5 | SL distance (x ATR) |
| InpRRTP | 1.5 | TP distance (x SL distance) |
| InpATRTrailMult | 2.0 | In-trade ATR trail (x ATR) |
#property copyright "Pipsgrowth.com"
#property link "https://pipsgrowth.com"
#property version "2.00"
#property strict
#property description "Pipsgrowth.com EX18020 USDJPY_Ultra_Aggressive_Martingale_EA — RSI+MACD scalper (martingale stripped, fixed-fractional), full 12-layer stack."
#include <Trade\Trade.mqh>
#include <Trade\PositionInfo.mqh>
#include <Trade\SymbolInfo.mqh>
#include <Trade\AccountInfo.mqh>
#include <Trade\OrderInfo.mqh>
#include <Trade\DealInfo.mqh>
CTrade g_trade;
CPositionInfo g_pos;
CSymbolInfo g_sym;
CAccountInfo g_acc;
//=================== INPUTS (19 total) ==============================
ENUM_TIMEFRAMES MapTimeframeInt(int tf)
{
switch(tf)
{
case 1: return PERIOD_M1;
case 2: return PERIOD_M5;
case 3: return PERIOD_M15;
case 4: return PERIOD_M30;
case 5: return PERIOD_H1;
case 6: return PERIOD_H4;
case 7: return PERIOD_D1;
default: return PERIOD_H1;
}
}
ENUM_APPLIED_PRICE MapAppliedPriceInt(int ap)
{
switch(ap)
{
case 1: return PRICE_CLOSE;
case 2: return PRICE_OPEN;
case 3: return PRICE_HIGH;
case 4: return PRICE_LOW;
case 5: return PRICE_MEDIAN;
case 6: return PRICE_TYPICAL;
case 7: return PRICE_WEIGHTED;
default: return PRICE_CLOSE;
}
}
ENUM_TIMEFRAMES g_InpHTF = PERIOD_H1;
input group "=== General ==="
input long InpMagic = 22218020; // Magic number (id)
input string InpTradeComment = "Psgrowth.com Expert_18020"; // Trade comment
input bool InpDryRun = true; // Dry-run: no real sends
input bool InpKillSwitch = false; // Kill switch (closes all on tick)
input double InpMaxSpreadPts = 35.0; // Max spread (points)
ENUM_TIMEFRAMES MapTimeframeInt(int tf)
{
switch(tf)
{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.