Pipsgrowth EX16019 Trend
MT5 Expert Advisor (Open Source) · XAUUSD · M5, H1
Pipsgrowth.com EX16019 BlackCrows_WhiteSoldiers_CCI — Candlestick pattern with CCI confirmation, full 12-layer stack.
Overview
EX16019 is a Japanese-candlestick reversal pattern EA, not a moving-average crossover or oscillator-momentum system. The core signal comes from two formations traders have studied for centuries — Three Black Crows at tops and Three White Soldiers at bottoms — and the EA looks for them with explicit body-size and midpoint-progression rules rather than a single 'candle pattern' indicator. The companion filter is a single Commodity Channel Index at period 37, which gates every entry and also drives a momentum-based early-exit rule. The default timeframe is M5 and the suggested symbol is XAUUSD, but the pattern rules and CCI configuration are identical across the FX majors and metals, so the EA ports cleanly to other instruments as long as the spread does not crowd the protective levels.
The pattern detector lives in the CheckPattern() function and works backwards through the three most recent completed bars. For a Three Black Crows sell signal, it imposes three conditions on each of bars 1, 2, and 3: the bar's open-minus-close distance must exceed the average candle body of the current bar, the body must be bearish (Open above Close), and the bar's midpoint, defined as (High+Low)/2, must step progressively lower — MidPoint(2) < MidPoint(3) followed by MidPoint(1) < MidPoint(2). The body threshold uses AvgBody(1), which averages the absolute open-close distance over InpAverBodyPeriod (default 12) bars, so a Crows pattern formed by small bodies is rejected even if the midpoints cascade correctly. The Three White Soldiers rule is the exact mirror: bullish bodies longer than average with MidPoint(2) > MidPoint(3) and MidPoint(1) > MidPoint(2) for ascending midpoints. Either formation flips ExtPatternDetected to true and the appropriate ExtSignalOpen to 1 (buy) or -1 (sell), and the ExtPatternInfo string records the detected formation in the Experts log so the operator can see what fired the trade.
The CCI confirmation sits in CheckConfirmation(). The function reads a single value, CCI(1), which is the CCI value on the most recently closed bar with period 37 and an applied price mapping controlled by InpPrice (1=close, 2=open, 3=high, 4=low, 5=median, 6=typical, 7=weighted; default 1=close). For a buy signal, the CCI must read below -50, an oversold read that is consistent with the bottoming Three White Soldiers pattern. For a sell signal, the CCI must read above +50, an overbought read that aligns with the topping Three Black Crows formation. If ExtPatternDetected is true but the CCI gate fails, the EA cancels the entry signal — no pattern-without-confirmation trades are sent. The CCI handle is created once in OnInit via iCCI(_Symbol, _Period, InpPeriodCCI, g_InpPrice) and released in OnDeinit, and there is no other indicator in the EA. This makes the indicator stack easy to audit: one handle, one oscillator, one period.
Entries execute in the second phase of OnTick once a new bar has been detected via the TimeCurrent() >= next_bar_open guard. The PositionOpen() function calls ExtTrade.Buy or ExtTrade.Sell at the current Ask or Bid with a fixed lot of InpLot = 0.1, the EA's magic number 22216019, and the trade comment 'Psgrowth.com Expert_16019'. There is no risk-based lot calculation — the lot is hard-set at the input value, so any change to position sizing has to be done by the operator manually. A single position is allowed per direction because PositionExist(ExtSignalOpen) gates the entry; if a position is already open in the same direction, the signal is dropped silently rather than pyramiding into it. Netting is also implicit because no opposite-direction entry is attempted while a position is open in the other direction either.
Stop-loss and take-profit are both 200 points by default — a 1:1 risk-reward ratio that depends entirely on point size. On XAUUSD with a 0.01 point, 200 points equals $2.00 of risk and $2.00 of reward per 0.1 lot, which is roughly 20 pips per side. The PositionOpen function has one unusual clause worth flagging: if the current spread in points is greater than or equal to the configured SL or TP, the EA falls back to using the spread itself as the protective level rather than rejecting the trade. That logic is a sanity check against negative stop distances on quiet pairs, but it means a spread spike of 30 points on a thin instrument can convert a configured 200-point stop into a 30-point stop at the moment of entry. Traders who set tight stops on instruments with variable spreads should pay attention, because the EA will quietly tighten protection when spreads widen, not the other way around.
The position-exit machinery is more layered than the entry side. The third phase of OnTick watches ExtSignalClose, which is set by CheckCloseSignal() and is independent of the entry pattern. Two conditions close a long: CCI(1) < 80 AND CCI(2) > 80 (CCI dropping out of overbought through the 80 line on a completed bar) and CCI(1) < -80 AND CCI(2) > -80 (CCI recovering from extreme oversold, used as a 'stop fighting the trade' exit). Two symmetric conditions close a short. Because these conditions read two completed bars, the early-exit triggers on the third completed bar after the pattern is detected at the earliest. The fourth phase is a hard time-based exit: if the position has been held for InpDuration = 10 bars on the active timeframe, the position is closed regardless of profit or loss. On an M5 chart that is roughly 50 minutes of exposure, on an H1 chart that is 10 hours.
Trade execution goes through CTrade and routes all close operations through TryClose_EX16019 and TryClosePartial_EX16019, both of which retry up to three times on TRADE_RETCODE_REQUOTE, TRADE_RETCODE_TIMEOUT, TRADE_RETCODE_PRICE_OFF, and TRADE_RETCODE_PRICE_CHANGED with 200ms sleeps between attempts. TryModify_EX16019 is defined in the same pattern but is not called by any of the active close flows — it is dead code in the current source, present for future stop-modification extensions. Slippage is controlled by InpSlippage = 10 points via ExtTrade.SetDeviationInPoints, and the standard deviation behavior is what most retail ECN feeds will accept without complaint.
What the EA does not contain is as important as what it does. There is no equity-stop, no daily-loss cap, no maximum-drawdown kill switch, no news filter, no spread filter beyond the SL/TP sanity check, no time-of-day filter, no OnTester optimization hook, and no OnTradeTransaction handler. The 12-layer architecture advertised in the source header is closer to the entry side than the safety side: REGIME is not present, SIGNAL (pattern + CCI gate) is present, ENTRY is present, CONFIRM is present, NO-TRADE is not wired, CAPITAL CAP is absent, RISK is the fixed 200-point SL, SIZING is the fixed 0.1 lot, MANAGE is the CCI early exit, EXIT is the time-based 10-bar close, SCALING is absent, OnTester is absent. Treat the header claim as an inventory of intentions rather than a current capability list, and decide whether the absent layers are acceptable for your risk tolerance before going live.
A runnable configuration starts with the platform requirements. The EA is portable to any MT5 symbol and timeframe, but the M5 chart on a low-spread XAUUSD broker is the most-tested combination. A tight-spread execution account will let the 200-point SL/TP behave as designed; a standard account where gold's spread routinely exceeds 20 points should be avoided, because the spread-sanity check will silently shrink the protective levels on every entry and the EA will keep trading on tighter protection than the inputs claim. Minimum recommended balance is $100, matching the EA's category minimum, and the lot is fixed at 0.1, so 200 points of risk on 0.1 lot of gold is roughly $20. The account should comfortably absorb a string of consecutive losses without margin pressure. The trading session is fully unrestricted: there is no day-of-week filter, no trading-hour filter, and no session-specific logic, which means the EA is technically live 24/5 including the Sunday-evening open and the Friday-afternoon close when spreads and volatility are unreliable.
Strategy Deep Dive
On every tick, the EA waits for a new bar of the active timeframe via the TimeCurrent gate, then runs a four-phase cycle. CheckPattern reads the three most recent closed bars and detects either Three Black Crows (three bearish bodies longer than the 12-bar average with progressively lower midpoints) or Three White Soldiers (the symmetric bullish pattern with rising midpoints). CheckConfirmation then reads CCI(37) on bar 1 and demands a value below -50 to confirm buys or above +50 to confirm sells — without confirmation, the signal is dropped. PositionOpen fires a single 0.1-lot market order with magic 22216019, a 200-point SL, and a 200-point TP, with a built-in spread sanity check that prevents negative protective levels by substituting the spread itself when it widens past the input. Active positions are managed by CheckCloseSignal (CCI 80/-80 level-cross exits) and CloseByTime (10-bar hard exit), each routed through 3-attempt retry helpers to absorb requotes and price-change errors.
EX16019 fires a buy on Three White Soldiers — three consecutive bullish bars, each with a body longer than the 12-bar average and progressively higher midpoints — confirmed by CCI(37) closing-bar read below -50. Sell entries fire on the symmetric Three Black Crows pattern with three bearish bodies longer than average and progressively lower midpoints, confirmed by CCI(37) above +50. Entries execute only on a new bar of the active timeframe with a fixed 0.1 lot and a single position per direction; no pyramiding and no opposite-direction entry while a position is open.
Long positions close when CCI(37) drops below 80 from above (overbought exit) or rises above -80 from below (extreme-oversold recovery exit), and shorts close on the symmetric cross. A hard time-based exit closes any position held for 10 bars of the active timeframe regardless of profit, which on M5 is roughly 50 minutes and on H1 is 10 hours. Both close paths route through 3-attempt retry helpers that absorb REQUOTE, TIMEOUT, PRICE_OFF, and PRICE_CHANGED errors with 200ms sleeps.
Stop loss is fixed at 200 points per trade via the InpSL input. If the live spread in points equals or exceeds the configured SL, the EA substitutes the spread itself as the stop distance at the moment of entry — a safety net against negative stops on quiet instruments that quietly tightens protection when spreads widen.
Take profit is also fixed at 200 points, giving a 1:1 risk-reward ratio. The same spread-sanity check applies to the TP — if the spread is wider than the configured TP, the spread itself becomes the target distance rather than the input value.
Best suited for traders running a tight-spread XAUUSD M5 execution with at least $100 starting capital, where the 200-point fixed SL/TP behaves as designed rather than being consumed by spread. The pattern-and-CCI logic ports to FX majors and other metals, but the M5 intraday window is where the 10-bar time-based exit matches the trading intent. Because there is no drawdown cap, no daily loss limit, and no news filter inside the EA, this belongs in disciplined hands — short testing sessions, or a trader's own account-level risk management rather than reliance on the EA to police itself.
Strategy Logic
Pipsgrowth EX16019 Trend — Strategy Logic Analysis (from .mq5 source)
Family: Trend
Magic: 22216019
Version: 2.00
BRIEF:
Candlestick pattern EA that detects Three Black Crows and Three White Soldiers formations, confirms with CCI oscillator, and enters with fixed SL/TP and time-based position exit. 12 layers: REGIME, SIGNAL, ENTRY, CONFIRM, NO-TRADE, CAPITAL CAP, RISK, SIZING, MANAGE, EXIT, SCALING, OnTester
INDICATOR STACK:
- Standard
MT5indicators
KEY FUNCTIONS:
CheckState()PositionOpen()CloseBySignal()CloseByTime()PositionExist()PositionExpiredByTimeExist()BarsHold()Open()Close()Low()High()MidPoint()- ...and 9 more
INTERNAL CONSTANTS (3 total):
SIGNAL_BUY= 1 // Buy signalSIGNAL_NOT= 0 // no trading signalCLOSE_LONG= 2 // signal to close Long
INPUT PARAMETERS (10 total across 2 groups):
- [===
STRATEGYPARAMETERS===]InpAverBodyPeriod= 12 // period for calculating average candlestick size - [===
STRATEGYPARAMETERS===]InpPeriodCCI= 37 //CCIperiod - [===
STRATEGYPARAMETERS===]InpPrice= 1 // Applied price (1=close,2=open,3=high,4=low,5=median,6=typical,7=weighted) // price type - [===
TRADEPARAMETERS===]InpDuration= 10 // position holding time in bars - [===
TRADEPARAMETERS===]InpSL= 200 // Stop Loss in points - [===
TRADEPARAMETERS===]InpTP= 200 // Take Profit in points - [===
TRADEPARAMETERS===]InpSlippage= 10 // slippage in points - [===
TRADEPARAMETERS===]InpLot=0.1// lot - [===
TRADEPARAMETERS===]InpMagicNumber=22216019// Magic Number - [===
TRADEPARAMETERS===]InpTradeComment= "Psgrowth.com Expert_16019" // TradeComment
// Pipsgrowth EX16019 Trend — Execution Flow (from source analysis)
// Family: Trend
// Candlestick pattern EA that detects Three Black Crows and Three White Soldiers formations, confirms with CCI oscillator, and enters with fixed SL/TP and time-based position exit. 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 |
|---|---|---|
| InpAverBodyPeriod | 12 | period for calculating average candlestick size |
| InpPeriodCCI | 37 | CCI period |
| InpPrice | 1 | Applied price (1=close,2=open,3=high,4=low,5=median,6=typical,7=weighted) // price type |
| InpDuration | 10 | position holding time in bars |
| InpSL | 200 | Stop Loss in points |
| InpTP | 200 | Take Profit in points |
| InpSlippage | 10 | slippage in points |
| InpLot | 0.1 | lot |
| InpMagicNumber | 22216019 | Magic Number |
| InpTradeComment | "Psgrowth.com Expert_16019" | Trade Comment |
#property copyright "Pipsgrowth.com"
#property link "https://pipsgrowth.com"
#property version "2.00"
#property strict
#property description "Pipsgrowth.com EX16019 BlackCrows_WhiteSoldiers_CCI — Candlestick pattern with CCI confirmation, full 12-layer stack."
#include <Trade\Trade.mqh>
#include <Trade\SymbolInfo.mqh>
#define SIGNAL_BUY 1 // Buy signal
#define SIGNAL_NOT 0 // no trading signal
#define SIGNAL_SELL -1 // Sell signal
#define CLOSE_LONG 2 // signal to close Long
#define CLOSE_SHORT -2 // signal to close Short
//--- Input parameters
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_APPLIED_PRICE g_InpPrice = PRICE_CLOSE;
input group "=== STRATEGY PARAMETERS ==="
input int InpAverBodyPeriod=12; // period for calculating average candlestick size
input int InpPeriodCCI =37; // CCI period
input int InpPrice = 1; // Applied price (1=close,2=open,3=high,4=low,5=median,6=typical,7=weighted) // price type
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_APPLIED_PRICE g_InpPrice = PRICE_CLOSE;
input group "=== TRADE PARAMETERS ==="
input uint InpDuration=10; // position holding time in bars
input uint InpSL =200; // Stop Loss in points
input uint InpTP =200; // Take Profit in points
input uint InpSlippage=10; // slippage in points
//--- money management parameters
input double InpLot =0.1; // lot
//--- Expert ID
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.