P
PipsGrowth
Trend FollowingOpen Source – Free

Pipsgrowth EX18015 TrendFollow

MT5 Expert Advisor (Open Source) · USDJPY · M15, M5, H1

Pipsgrowth.com EX18015 USDJPY_Enhanced_Aggressive_EA — multi-indicator score confluence (Hull+MACD+RSI), full 12-layer stack.

Overview

EX18015 is a USDJPY-tuned trend-following EA that scores a closed bar against four independent momentum/trend readings and only fires when at least three of them line up on the same side. The decision happens entirely on the freshly-closed bar (shift=1 in the source), so the EA does not repaint on the live tick and the on-chart dashboard does not refresh on every quote.

The four votes are: a custom inlined Hull Moving Average, a MACD(12,26,9) main/signal cross plus zero-line test, and an RSI(14) side-of-50 test. The Hull is built from two linear-weighted moving averages (one of period 14, one of period 7), differenced, then re-weighted by a triangular sqrt(14) approximately 4-tap LWMA — a real Hull construction, not a one-line iMA call. The MACD vote has two components (main>signal AND main>0 for a buy) and the RSI vote is binary (>50 = buy, <50 = sell), so the confluence is genuinely four independent sub-signals. A buy needs InpMinConfluence of the four (default 3) and must beat the bear count, with the resulting confidence stored as a 25/50/75/100 percentage that the dashboard prints.

Regime is a separate 7-state classifier that runs once per tick. STRONG_TREND requires ADX(14) >= 30, WEAK_TREND requires ADX >= the user-defined InpAdxThreshold (default 20), COMPRESS is a 10%+ Bollinger Band width contraction, EXPAND is a 10%+ expansion, BREAKOUT requires the current ATR to be >= 1.2x the previous bar's ATR, and RANGE is the default fallback. ATR(14) percentile is computed across a 100-bar lookback window; if percentile > 80 and ADX has dropped below 18, the classifier overrides the current state to CHOPPY. The CHOPPY and COMPRESS states veto entries outright, which keeps the EA out of the flat markets where trend systems bleed equity.

Confirmation is a three-part gate that runs after the signal votes. (1) The higher-timeframe H1 EMA(50) vs EMA(200) must agree with the trade direction — a buy needs fast>slow, a sell needs fast<slow, no exceptions. (2) The current spread must be <= InpMaxSpreadPts (default 35 points). (3) ATR percentile must sit in a 15-95 band — too quiet or too spiky both fail. All three must pass for ConfirmPass() to return true.

The NO-TRADE block is the safety layer. It rejects entries when: the kill switch is on, effective capital is below the $50 floor, peak-to-trough drawdown has hit 25%, a 5-bar cooldown is in force after 3 consecutive losses, today's 10-trade daily cap is full, the realized daily loss has crossed 3% of effective capital, the realized weekly loss has crossed 9% of effective capital, the open-position count is at the InpMaxConcurrent cap (default 1), or the server clock is inside the weekend guard (Saturday/Sunday all day, Friday 22:00 onward, Monday before 02:00). The 9% weekly limit is the tightest in the EX18 family and is the single biggest structural difference between EX18015 and the otherwise similar 4-vote EX18011.

Position management runs every tick for each open ticket. Stop loss is InpAtrSlMult x ATR(14) = 1.8xATR by default; take profit is InpMinRR x SL = 1.5R, so a 1:1.5 R:R ratio (TP at 2.7xATR). Lot size is computed from the risk formula effCap * 0.5% / lossPerLot, floored to the symbol's LotsStep() and clamped by the 5-lot hard cap. Once price reaches +1.0R, TryModify_EX18015 ratchets the stop to breakeven plus a 2-pip buffer (one-shot, never tightens further by itself). At +1.5R, TryClosePartial_EX18015 closes 50% of the position to lock half the move. After +1.0R, the trailing stop kicks in at 2.0xATR behind price, with TryModify_EX18015 only ever moving the SL forward.

There are two hard exits besides SL/TP. The regime-flip exit calls RegimeDetect() and HullColor() again on the open position; if the regime is still STRONG_TREND but the Hull color has flipped, the position is closed immediately — this is the EA's "trend is broken" exit. The time exit closes any position that has been open for MAX_BARS_IN_TRADE = 200 bars (about 50 hours on M15) regardless of P&L, which prevents the EA from carrying a dead trade through a weekend or news cycle.

Pyramiding is off by default (InpPyramidEnabled = false). If the user enables it, up to 3 adds are allowed, each spaced PYRAMID_ATR_SPACING x ATR(14) = 1.5xATR beyond the previous entry, with the same SL/TP formula and risk sizing as the initial position. The 1-concurrent default in the safety layer means that with pyramid off, only one position at a time is allowed; with pyramid on, up to 3 same-direction positions can be open.

The OnTester custom criterion is (netProfit * profitFactor) / (1 + relativeDrawdown) with a 30-trade minimum floor — strategies that pass the gate with low trade counts or negative PF are auto-rejected by the optimizer. Order sends use trade.SetDeviationInPoints(20) and one retry on requote/timeout/price-changed, which is the standard EX18 retry pattern.

What to expect in backtest: with default confluence=3 and 1-concurrent cap, EX18015 trades less often than a 2-vote system, but each trade carries a 1:1.5 R:R and the 50%-partial at +1.5R means the average realized R is structurally positive on winners. The biggest performance lever is InpAdxThreshold — lowering it to 15 turns on more signals but also lets the EA trade in WEAK_TREND that would otherwise be filtered. The 9% weekly cap will halt the EA for the rest of the week after a bad Monday, so expect clustering of trades early in the week and silence from Thursday onward in drawdowns.

Strategy Deep Dive

EX18015 builds an inlined Hull MA from two LWMA(14) and LWMA(7) handles, differenced and re-weighted with a sqrt(14) approximately 4-tap triangular kernel, so the color flip reflects real Hull curvature rather than a smoothed price line. Each closed bar the EA tallies four independent votes — Hull color, MACD main/signal cross + zero-side, RSI(14) side — and only opens a position when the bull/bear count clears InpMinConfluence (default 3) and the higher-timeframe H1 EMA stack agrees. The 7-state regime classifier (ADX-30 strong, ADX-20 weak, BB-width compress/expand/breakout, range, choppy) runs in parallel and vetoes entries during CHOPPY and COMPRESS states. OnTick wires the layers together: regime -> no-trade block -> signal score -> confirm pass -> market send with one retry, then a ManagePositions loop applies BE/partial/trail and the two hard exits. Position sizing reads the risk formula straight from EffectiveCapital(), so a $100 account with default 0.5% risk never risks more than $0.50 per trade.

Entry Signal

EX18015 enters on the closed bar (shift=1) when at least 3 of 4 confluence votes agree: inlined Hull MA color (sqrtP-weighted 14-period LWMA composite), MACD(12,26,9) main>signal and main>0, and RSI(14) >50 (or the symmetric set for shorts). A buy additionally requires H1 EMA(50)>EMA(200) agreement, an ADX gate (default 20), ATR-percentile between 15 and 95, and the regime classifier returning anything other than CHOPPY or COMPRESS. Max 1 concurrent position by default with a 3-loss -> 5-bar cooldown.

Exit Signal

Positions are closed by TP at +1.5R (1.8xATR x 1.5 = 2.7xATR), by the regime-flip exit (regime still STRONG_TREND but Hull color has flipped), by the 200-bar time stop, or by the standard SL hit. Manage runs every tick: breakeven + 2 pips buffer is applied at +1.0R (one-shot), 50% partial close at +1.5R, and a 2.0xATR trailing stop kicks in after +1.0R, only ever moving forward.

Stop Loss

Stop loss is fixed at InpAtrSlMult (default 1.8) x ATR(14) at entry, with a hard peak-to-trough drawdown cap of 25% on effective capital that closes everything and blocks new entries for the rest of the day. Once price reaches +1.0R, the stop is ratcheted to breakeven + 2 pips as a one-shot move, and from there the 2.0xATR trailing stop takes over.

Take Profit

Take profit is InpMinRR x SL distance (default 1.5R = 2.7xATR), with a 50% partial close executed at +1.5R to lock in half the move before the full TP is reached. The 1:1.5 R:R ratio is the EA's structural edge — the partial reduces the average loser size even when the full TP doesn't hit, since the trailing stop or regime-flip exit often takes the remaining half at less than full target.

Best For

Best paired with a USDJPY M15 chart on an ECN or low-spread broker — InpMaxSpreadPts = 35 will reject entries on most retail accounts during Asian-session widening. Minimum recommended balance: $100 (matches the InpCapitalCapFloor of $50 with comfortable headroom), and the 0.5% default risk and 1-concurrent cap make this appropriate for prop-firm challenge accounts and small retail books alike. The 9% weekly loss cap and 200-bar time exit mean the EA is suited to traders who prefer a low-frequency, high-quality setup over a high-turnover system, and the InpDryRun = true default means the file can be attached to a chart for evaluation without sending orders.

Strategy Logic

Pipsgrowth EX18015 TrendFollow — Strategy Logic Analysis (from .mq5 source)

Family: TrendFollow Magic: 22218015 Version: 2.00

BRIEF: Multi-indicator score confluence on closed bar. Signal: Hull-MA color + MACD main/signal cross + MACD zero-side + RSI (50) side; require >=MinConfluence of 4, ADX gate. Layered with REGIME(ADX+ATR%ile+BBw), CONFIRM(HTF-EMA+spread+session), full NO-TRADE filter, CAPITAL-CAP, RISK, SIZING, MANAGE/EXIT (BE + partial + ATR trail + regime-flip + time), SCALING (pyramid OFF by default), EXEC, OnTester. De-risked from original thesis. 12 layers: REGIME, SIGNAL, ENTRY, CONFIRM, NO-TRADE, CAPITAL CAP, RISK, SIZING, MANAGE, EXIT, SCALING, OnTester

INDICATOR STACK:

  • Standard MT5 indicators

KEY FUNCTIONS:

  • RegimeDetect()
  • HullGetValue()
  • HullColor()
  • SignalScore()
  • ConfirmPass()
  • NoTradeBlock()
  • CountOpenByMagic()
  • CloseAllByMagic()
  • EffectiveCapital()
  • UpdateDailyWeekly()
  • PushSpread()
  • SpreadMean()
  • ...and 9 more

INTERNAL CONSTANTS (1 total):

  • ROLLING_SPREAD_LOOK = 50 // +------------------------------------------------------------------+

INPUT PARAMETERS (18 total across 6 groups):

  • [=== IDENTITY ===] InpMagic = 22218015 // Magic number
  • [=== IDENTITY ===] InpComment = "Psgrowth.com Expert_18015" // Trade comment
  • [=== IDENTITY ===] InpDryRun = true // Dry-run (no live sends)
  • [=== IDENTITY ===] InpKillSwitch = false // Kill switch (close-all+halt)
  • [=== CAPITAL CAP (effective_capital) ===] InpCapitalCapAmount = 0.0 // Real-money cap ($)
  • [=== CAPITAL CAP (effective_capital) ===] InpCapitalCapFloor = 50.0 // Below floor: entries blocked
  • [=== RISK & SIZING ===] InpRiskPercent = 0.5 // Risk per trade (% of eff_cap)
  • [=== RISK & SIZING ===] InpDailyLossLimitPct = 3.0 // Daily loss limit (% eff_cap)
  • [=== RISK & SIZING ===] InpWeeklyLossLimitPct = 9.0 // Weekly loss limit (% eff_cap)
  • [=== RISK & SIZING ===] InpAtrSlMult = 1.8 // SL = mult * ATR(14)
  • [=== RISK & SIZING ===] InpMinRR = 1.5 // Minimum reward:risk
  • [=== RISK & SIZING ===] InpMaxConcurrent = 1 // Max concurrent positions (this magic)
  • [=== RISK & SIZING ===] InpCooldownLosses = 3 // Pause after N consecutive losses
  • [=== SIGNAL ===] InpMinConfluence = 3 // Min confluence score (of 4)
  • [=== SIGNAL ===] InpAdxThreshold = 20.0 // ADX threshold (trend gate)
  • [=== CONFIRM / EXEC ===] InpMaxSpreadPts = 35 // Max spread (points)
  • [=== CONFIRM / EXEC ===] InpTrailAtrMult = 2.0 // ATR trailing multiplier
  • [=== SCALING (Pyramid) ===] InpPyramidEnabled = false // Pyramid OFF by default
Pseudocode
// Pipsgrowth EX18015 TrendFollow — Execution Flow (from source analysis)
// Family: TrendFollow
// Multi-indicator score confluence on closed bar. Signal: Hull-MA color + MACD main/signal cross + MACD zero-side + RSI (50) side; require >=MinConfluence of 4, ADX gate. Layered with REGIME(ADX+ATR%ile+BBw), CONFIRM(HTF-EMA+spread+session), full NO-TRADE filter, CAPITAL-CAP, RISK, SIZING, MANAGE/EXIT (BE + partial + ATR trail + regime-flip + time), SCALING (pyramid OFF by default), EXEC, OnTester. De-risked from original thesis. 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:
USDJPY
Optimized Timeframes:
M15M5H1

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 an H4 or Daily chart for best results
  7. 7Configure EMA periods, ADX threshold, and lot size in the dialog
  8. 8Enable Allow Algo Trading and click OK

EA Parameters

ParameterDefaultDescription
InpMagic22218015Magic number
InpComment"Psgrowth.com Expert_18015"Trade comment
InpDryRuntrueDry-run (no live sends)
InpKillSwitchfalseKill switch (close-all+halt)
InpCapitalCapAmount0.0Real-money cap ($)
InpCapitalCapFloor50.0Below floor: entries blocked
InpRiskPercent0.5Risk per trade (% of eff_cap)
InpDailyLossLimitPct3.0Daily loss limit (% eff_cap)
InpWeeklyLossLimitPct9.0Weekly loss limit (% eff_cap)
InpAtrSlMult1.8SL = mult * ATR(14)
InpMinRR1.5Minimum reward:risk
InpMaxConcurrent1Max concurrent positions (this magic)
InpCooldownLosses3Pause after N consecutive losses
InpMinConfluence3Min confluence score (of 4)
InpAdxThreshold20.0ADX threshold (trend gate)
InpMaxSpreadPts35Max spread (points)
InpTrailAtrMult2.0ATR trailing multiplier
InpPyramidEnabledfalsePyramid OFF by default
Source Code (.mq5)Open Source
Pipsgrowth_com_EX18015.mq5
#property copyright "Pipsgrowth.com"
#property link      "https://pipsgrowth.com"
#property version   "2.00"
#property strict
#property description "Pipsgrowth.com EX18015 USDJPY_Enhanced_Aggressive_EA — multi-indicator score confluence (Hull+MACD+RSI), full 12-layer stack."

#include <Trade\Trade.mqh>
#include <Trade\PositionInfo.mqh>
#include <Trade\AccountInfo.mqh>
#include <Trade\SymbolInfo.mqh>
#include <Trade\OrderInfo.mqh>
#include <Trade\DealInfo.mqh>

CTrade        trade;
CPositionInfo posInfo;
CAccountInfo  acct;
CSymbolInfo   sym;

//+------------------------------------------------------------------+
//| TUNABLE CONSTANTS (non-input knobs)                              |
//+------------------------------------------------------------------+
#define ADX_PERIOD           14
#define ATR_PERIOD           14
#define RSI_PERIOD           14
#define MACD_FAST            12
#define MACD_SLOW            26
#define MACD_SIGNAL          9
#define BB_PERIOD            20
#define BB_DEVIATION         2.0
#define HULL_PERIOD          14
#define HTF_TF               PERIOD_H1
#define HTF_EMA_FAST         50
#define HTF_EMA_SLOW         200
#define ATR_PCTILE_LOOKBACK  100
#define BE_TRIGGER_R         1.0
#define BE_OFFSET_PIPS       2.0
#define PARTIAL_TRIGGER_R    1.5
#define PARTIAL_PCT          50.0
#define TRAIL_TRIGGER_R      1.0
#define MAX_PYRAMID_LEVELS   3
#define PYRAMID_ATR_SPACING  1.5
#define MAX_DAILY_TRADES     10
#define COOLDOWN_BARS        5
#define MAX_BARS_IN_TRADE    200
#define SLIPPAGE_POINTS      20
#define MAX_LOTS_HARD_CAP    5.0
#define ROLLING_SPREAD_LOOK  50

//+------------------------------------------------------------------+
//| INPUTS (21 — within 12-22 cap)                                   |
//+------------------------------------------------------------------+
input group "=== IDENTITY ==="
input long   InpMagic              = 22218015;                    // Magic number
input string InpComment            = "Psgrowth.com Expert_18015"; // Trade comment
input bool   InpDryRun             = true;                       // Dry-run (no live sends)
input bool   InpKillSwitch         = false;                      // Kill switch (close-all+halt)

input group "=== CAPITAL CAP (effective_capital) ==="
// InpCapitalCapEnabled removed — use InpCapitalCapAmount=0 to disable                       // Enable capital cap
input double InpCapitalCapAmount   = 0.0;                      // Real-money cap ($)

Full source code available on download

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

Tags:ex18015trendfollowpipsgrowthfreemt5usdjpy

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_EX18015.mq5
File Size34.1 KB
Versionv2.00
PlatformMetaTrader 5
File Type.mq5 Source
StrategyTrend Following
Risk LevelMedium Risk
Timeframes
M15M5H1
Currency Pairs
USDJPY
Min. Deposit$100