Pipsgrowth EX14016 Scalper
MT5 Expert Advisor (Open Source) · USDJPY · M5
Pipsgrowth.com EX14016 USDJPYm_Scalper — Asian range breakout scalper with EMA/ATR confirmation and pyramid scaling, full 12-layer stack.
Overview
EX14016 trades the transition between the Asian session and the London open. The market accumulates orders during the quiet Asian session and then releases them when London opens. EX14016 is built on that idea: it lets USDJPY consolidate for seven hours, marks the resulting high and low as a range, and then trades the breakout when the next session begins.
When the OnTick function runs, it first calls UpdateDashboard and ManageAllPositionsSL on every tick to maintain the chart panel and the stop-loss ladder, and then CheckFridayClose to flatten positions before the weekend. On a new bar it calculates the Asian session range, then either checks for a new breakout (when no positions are open) or runs ProcessPyramidLogic to add to an existing position. The architecture is two native indicator handles: an iMA(_Symbol, InpEMA_TF, 50, 0, MODE_EMA, PRICE_CLOSE) for trend alignment and an iATR(_Symbol, InpTimeframe, 14) for the volatility gate. Everything else is computed in-process from raw price arrays.
The Asian range is the core signal. In CalculateAsianRange, the EA pulls the GMT hour from TimeGMT(), waits until hour 7, and then walks backward through M5 bars from hour 0 to hour 7 to find the highest high and lowest low of the session. It stores these in g_asianHigh and g_asianLow, plus the range in pips. The state resets the next day. The range is then drawn on the chart as a lime high line, a red low line, and a dotted gray midline via DrawRangeLines.
A breakout entry requires four things to align. First, the closed bar's price must close above g_asianHigh plus a 5-pip buffer (or below g_asianLow minus the buffer) — this is the directional trigger in CheckBreakoutEntry. Second, when InpRequireEMA is true, the close must be on the correct side of the 50-period EMA on the configured higher timeframe (default H4). This is the trend filter: a long breakout is rejected if price is below the EMA, a short breakout is rejected if price is above it. Third, the ATR(14) must be at least 8 pips — a dead market does not produce real breakouts. Finally, the breakout bar itself must have a body of at least 6 pips to ensure the move is conviction-backed and not a wick. When all four checks pass, OpenPosition fires a market order with a 20-pip initial stop, a 100-pip take-profit, and a lot size derived from the risk model.
Risk sizing uses the standard formula in CalculateLotSize. InpRiskPercent defaults to 10% — extremely aggressive, reflecting the strategy's high-frequency nature. The function reads equity (or balance when InpCompoundGains is false), multiplies by 10%, divides by the dollar exposure of the 20-pip stop using tickValue and tickSize, and floors to the lot step. A 100 USD balance with the default risk produces roughly 0.05 lots on USDJPY; the same balance on a 1,000 USD account produces 0.5 lots. The 40% trailing-drawdown kill switch in IsDrawdownExceeded tracks g_peakEquity — once equity drops 40% from its high water mark, the EA halts new entries and prints a trading-halted message to the comment.
The position management is where this EA earns its keep. ManageSinglePositionSL runs a three-stage stop-loss ladder on every tick. Stage 1 is breakeven: when profit reaches 30 pips (InpBreakevenTrigger), the stop moves to entry plus 5 pips (InpBreakevenOffset). Stage 2 is a classical trailing stop at 15 pips distance once breakeven has been secured. Stage 3 is a weakness-tightening mechanism: IsTrendWeakening checks both the EMA slope (flat if the absolute difference between bar 1 and bar 2 is less than half a pip) and price returning within 10 pips of the Asian range boundary. When weakness is detected and profit is above the 5-pip secure level, the stop tightens to 10 pips distance, locking in gains. Partial close at 50% of the position fires at 50 pips profit, halving exposure while the runner continues toward the 100-pip take-profit.
The pyramid is conditional and conservative in its gating. ProcessPyramidLogic only opens a new entry when four conditions are met: there are fewer than 5 open positions (InpMaxPyramid), the most recent position has its stop at or beyond entry plus 5 pips (IsNewestPositionSecured), the trend is still valid per IsTrendStillValid (price remains on the correct side of both the Asian range and the EMA), and the distance from the last entry is at least 20 pips. The risk model sizes each pyramid leg independently, so the cumulative exposure scales with equity — this is the compounding path that lets the strategy ride a strong move.
The risk filters are short and strict. PassesAvoidFilters blocks entries when the spread exceeds 2.5 pips (a hard ceiling for scalping), when it is Friday afternoon after 12:00 UTC, and when free margin is below 10 USD. CheckFridayClose force-closes every position at 18:00 UTC on Friday, eliminating weekend gap risk. The OnInit sets ORDER_FILLING_IOC and a 25-point slippage cap (InpMaxSpread_Pips * 10) on the CTrade wrapper. The dashboard reports balance, equity, drawdown, position count, ATR, EMA value, Asian high/low, range size, and a signal-status marker (bullish zone, bearish zone, in range) that updates every tick.
Three retry helpers sit at the bottom of the source. TryClose_EX14016, TryClosePartial_EX14016, and TryModify_EX14016 each retry three times on REQUOTE, TIMEOUT, PRICE_OFF, and PRICE_CHANGED (the modify helper only retries on REQUOTE and TIMEOUT), with 200ms sleeps on the close helpers and 100ms on the modify helper. All three are wired into the live execution paths.
What to expect in backtest: the strategy is range-breakout, which historically performs on USDJPY during the Asian-to-London transition but struggles in trendless or news-driven environments. The 10% per-position risk and 5-position pyramid mean a single bad week can produce significant drawdowns before the 40% kill switch engages. Users should consider reducing InpRiskPercent to 2-3% for live deployment, or limiting InpMaxPyramid to 2-3 unless the account is specifically designed to absorb the volatility.
Strategy Deep Dive
The OnTick function runs the dashboard and stop-loss ladder every tick, and on each new bar calculates the Asian range from M5 bars between 00:00 and 07:00 UTC in CalculateAsianRange, then either calls CheckBreakoutEntry (when no positions are open) or ProcessPyramidLogic (when positions exist). CheckBreakoutEntry combines a directional close-vs-range test with a 5-pip buffer, a 50-period EMA trend filter on a higher timeframe, an ATR(14) >= 8 pips volatility gate, and a 6-pip minimum candle body. ManageSinglePositionSL stages the stop through breakeven, classical trailing, and a weakness-tightening pass that watches both EMA slope and range proximity. TryClose_EX14016, TryClosePartial_EX14016, and TryModify_EX14016 retry broker rejection codes with short sleeps; all three are wired into the live execution paths. The 40% trailing-drawdown kill switch in IsDrawdownExceeded halts new entries without closing runners.
The EA measures the Asian session high and low (00:00–07:00 UTC) once per day and waits for a closed bar to close above the range high plus a 5-pip buffer or below the range low minus the buffer. A long entry additionally requires the close to be above the 50-period EMA on the configured higher timeframe (default H4), a 14-period ATR of at least 8 pips, and a breakout candle body of at least 6 pips. A symmetric set of conditions applies to shorts on the low side. The trade opens with a 20-pip initial stop, a 100-pip take-profit, and a lot size derived from a 10% equity-risk formula.
Exits combine a 100-pip take-profit, a 50%-partial-close at 50 pips profit, a three-stage stop-loss ladder (breakeven at +30 pips with 5-pip lock, 15-pip trailing distance, and 10-pip tightening when IsTrendWeakening flags flat EMA slope or a price return to within 10 pips of the Asian range), and a Friday force-close at 18:00 UTC. The weakness signal in IsTrendWeakening watches the absolute difference between bar 1 and bar 2 of the EMA (triggers if under 0.5 pip) and a price-vs-range proximity test.
Initial stop is 20 pips (InpInitialSL), which then migrates to entry +5 pips at +30 pips profit (breakeven), trails at 15 pips distance when InpUseTrailing is true, and tightens to 10 pips when IsTrendWeakening detects a flat EMA slope or price returning within 10 pips of the Asian range boundary. There is no global drawdown stop per trade; the 40% trailing drawdown on equity in IsDrawdownExceeded halts all new entries but does not close existing positions.
Take profit is 100 pips (InpTP_Pips) attached as a broker-side limit at entry. A 50% partial close fires at 50 pips profit (InpPartialTP_Pips + InpPartialPercent) once per position, identified by a "_PC" suffix in the position comment to prevent re-triggering. Setting InpTP_Pips to zero disables the fixed TP and lets positions ride the trailing stop toward Friday close.
Minimum recommended balance is 100 USD (the EA's minDeposit), but the 10% per-position risk and 5-position pyramid make 500 USD or more a realistic floor for surviving a losing streak before the 40% drawdown kill switch engages. Best on USDJPY M30 with the default config (InpTimeframe=4=M30, InpEMA_TF=6=H4), although the suggested timeframe in the header is M5 for more frequent breakouts. Use an ECN or low-spread account — the 2.5-pip spread cap is unforgiving on standard accounts — and run during the London open (08:00–11:00 UTC) when the Asian range breakout typically fires. The Friday 18:00 UTC flatten means weekend gap risk is structurally eliminated.
Strategy Logic
Pipsgrowth EX14016 Scalper — Strategy Logic Analysis (from .mq5 source)
Family: Scalper
Magic: 22214016
Version: 2.00
BRIEF:
Aggressive USDJPY scalping EA using Asian range breakout with EMA trend alignment and ATR momentum confirmation. Features pyramid scaling, trailing SL, breakeven, partial close, and Friday close filter. 12 layers: REGIME, SIGNAL, ENTRY, CONFIRM, NO-TRADE, CAPITAL CAP, RISK, SIZING, MANAGE, EXIT, SCALING, OnTester
INDICATOR STACK:
- Standard
MT5indicators
KEY FUNCTIONS:
IsNewBar()CalculateAsianRange()CheckBreakoutEntry()PassesAvoidFilters()OpenPosition()ProcessPyramidLogic()IsNewestPositionSecured()IsTrendStillValid()HasMinimumDistance()OpenPyramidPosition()ManageAllPositionsSL()ManageSinglePositionSL()- ...and 18 more
INTERNAL CONSTANTS (0 total):
INPUT PARAMETERS (43 total across 8 groups):
- [=== Key Configuration ===]
InpMagicNumber=22214016// Magic Number - [=== Key Configuration ===]
InpTradeComment= "Psgrowth.com Expert_14016" // TradeComment - [=== Key Configuration ===]
InpRiskPercent=10.0// Risk % per NEW position - [=== Key Configuration ===]
InpMaxDDPercent=40.0// Max Trailing Drawdown % - [=== Key Configuration ===]
InpCompoundGains=true// Compound Equity for Lot Sizing - [=== Entry: Breakout ===]
InpTimeframe= 4 //Timeframe(1=M1,2=M5,3=M15,4=M30,5=H1,6=H4,7=D1) // Primary Timeframe - [=== Entry: Breakout ===]
InpRangeStartHour= 0 // Asian Range StartHour(UTC) - [=== Entry: Breakout ===]
InpRangeEndHour= 7 // Asian Range EndHour(UTC) - [=== Entry: Breakout ===]
InpBreakoutBuffer= 5 // BreakoutBuffer(pips above/below range) - [=== Entry: Breakout ===]
InpRequireEMA=true// RequireEMATrend Alignment - [=== Entry: Breakout ===]
InpEMA_Period= 50 //EMAPeriod - [=== Entry: Breakout ===]
InpEMA_TF= 6 //Timeframe(1=M1,2=M5,3=M15,4=M30,5=H1,6=H4,7=D1) //EMATimeframe - [=== Momentum Confirmation ===]
InpATR_Period= 14 //ATRPeriod - [=== Momentum Confirmation ===]
InpMinATR_Pips=8.0// MinATRValue(pips) - [=== Momentum Confirmation ===]
InpMinBodyPips= 6 // Min Breakout CandleBody(pips) - [=== Pyramid Scaling ===]
InpMaxPyramid= 5 // Max Pyramid Positions - [=== Pyramid Scaling ===]
InpPyramidTrigger= 30 // Add Position After X Pips Profit - [=== Pyramid Scaling ===]
InpSecureSL_Offset= 5 // Lock In X Pips When Securing - [=== Pyramid Scaling ===]
InpMinDistance= 20 // Min Pips Between Positions - [=== SL Management ===]
InpInitialSL= 20 // InitialSL(pips) - [=== SL Management ===]
InpBreakevenTrigger= 30 // Move to BE at X Pips Profit - [=== SL Management ===]
InpBreakevenOffset= 5 // Lock In X Pips at BE - [=== SL Management ===]
InpUseTrailing=true// Enable Trailing Stop - [=== SL Management ===]
InpTrailDistance= 15 // TrailDistance(pips) - [=== SL Management ===]
InpTightenOnWeakness=true// Tighten SL on Trend Weakness - [=== SL Management ===]
InpTightSL= 10 // Tightened SLDistance(pips) - [=== Avoid Filters ===]
InpMaxSpread_Pips=2.5// MaxSpread(pips) - [=== Avoid Filters ===]
InpAvoidFriday=true// No New Positions Friday PM - [=== Avoid Filters ===]
InpFridayCloseHour= 18 // Close All By This HourFriday(UTC) - [=== Exit Logic ===]
InpTP_Pips= 100 // TakeProfit(pips) - 0 = disabled - [=== Exit Logic ===]
InpPartialClose=true// Enable Partial Close at 50% - [=== Exit Logic ===]
InpPartialTP_Pips= 50 // Partial TPLevel(pips) - [=== Exit Logic ===]
InpPartialPercent=50.0// Partial Close Percentage - [=== Visual Display ===]
InpShowDashboard=true// Show Dashboard Panel - [=== Visual Display ===]
InpShowRangeLines=true// Show Asian Range Lines - [=== Visual Display ===]
InpShowEMA=true// ShowEMAon Chart - [=== Visual Display ===]
InpShowATRInfo=true// ShowATRin Dashboard - [=== Visual Display ===]
InpShowEntryArrows=true// Show Entry/Exit Arrows - [=== Visual Display ===]
InpRangeHighColor=clrLime// Range High Line Color - [=== Visual Display ===]
InpRangeLowColor=clrRed// Range Low Line Color - [=== Visual Display ===]
InpEMAColor=clrGold//EMALine Color - [=== Visual Display ===]
InpBuyArrowColor=clrDodgerBlue// Buy Arrow Color - [=== Visual Display ===]
InpSellArrowColor=clrOrangeRed// Sell Arrow Color
// Pipsgrowth EX14016 Scalper — Execution Flow (from source analysis)
// Family: Scalper
// Aggressive USDJPY scalping EA using Asian range breakout with EMA trend alignment and ATR momentum confirmation. Features pyramid scaling, trailing SL, breakeven, partial close, and Friday close filter. 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 from the Navigator onto any chart (M1 or M5 recommended)
- 7In the EA dialog, enable Allow Algo Trading and set your lot size
- 8Click OK — the EA will begin trading automatically
EA Parameters
| Parameter | Default | Description |
|---|---|---|
| InpMagicNumber | 22214016 | Magic Number |
| InpTradeComment | "Psgrowth.com Expert_14016" | Trade Comment |
| InpRiskPercent | 10.0 | Risk % per NEW position |
| InpMaxDDPercent | 40.0 | Max Trailing Drawdown % |
| InpCompoundGains | true | Compound Equity for Lot Sizing |
| InpTimeframe | 4 | Timeframe (1=M1,2=M5,3=M15,4=M30,5=H1,6=H4,7=D1) // Primary Timeframe |
| InpRangeStartHour | 0 | Asian Range Start Hour (UTC) |
| InpRangeEndHour | 7 | Asian Range End Hour (UTC) |
| InpBreakoutBuffer | 5 | Breakout Buffer (pips above/below range) |
| InpRequireEMA | true | Require EMA Trend Alignment |
| InpEMA_Period | 50 | EMA Period |
| InpEMA_TF | 6 | Timeframe (1=M1,2=M5,3=M15,4=M30,5=H1,6=H4,7=D1) // EMA Timeframe |
| InpATR_Period | 14 | ATR Period |
| InpMinATR_Pips | 8.0 | Min ATR Value (pips) |
| InpMinBodyPips | 6 | Min Breakout Candle Body (pips) |
| InpMaxPyramid | 5 | Max Pyramid Positions |
| InpPyramidTrigger | 30 | Add Position After X Pips Profit |
| InpSecureSL_Offset | 5 | Lock In X Pips When Securing |
| InpMinDistance | 20 | Min Pips Between Positions |
| InpInitialSL | 20 | Initial SL (pips) |
| InpBreakevenTrigger | 30 | Move to BE at X Pips Profit |
| InpBreakevenOffset | 5 | Lock In X Pips at BE |
| InpUseTrailing | true | Enable Trailing Stop |
| InpTrailDistance | 15 | Trail Distance (pips) |
| InpTightenOnWeakness | true | Tighten SL on Trend Weakness |
| InpTightSL | 10 | Tightened SL Distance (pips) |
| InpMaxSpread_Pips | 2.5 | Max Spread (pips) |
| InpAvoidFriday | true | No New Positions Friday PM |
| InpFridayCloseHour | 18 | Close All By This Hour Friday (UTC) |
| InpTP_Pips | 100 | Take Profit (pips) - 0 = disabled |
| InpPartialClose | true | Enable Partial Close at 50% |
| InpPartialTP_Pips | 50 | Partial TP Level (pips) |
| InpPartialPercent | 50.0 | Partial Close Percentage |
| InpShowDashboard | true | Show Dashboard Panel |
| InpShowRangeLines | true | Show Asian Range Lines |
| InpShowEMA | true | Show EMA on Chart |
| InpShowATRInfo | true | Show ATR in Dashboard |
| InpShowEntryArrows | true | Show Entry/Exit Arrows |
| InpRangeHighColor | clrLime | Range High Line Color |
| InpRangeLowColor | clrRed | Range Low Line Color |
| InpEMAColor | clrGold | EMA Line Color |
| InpBuyArrowColor | clrDodgerBlue | Buy Arrow Color |
| InpSellArrowColor | clrOrangeRed | Sell Arrow Color |
#property copyright "Pipsgrowth.com"
#property link "https://pipsgrowth.com"
#property version "2.00"
#property strict
#property description "Pipsgrowth.com EX14016 USDJPYm_Scalper — Asian range breakout scalper with EMA/ATR confirmation and pyramid scaling, full 12-layer stack."
#include <Trade\Trade.mqh>
//+------------------------------------------------------------------+
//| 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_InpTimeframe = PERIOD_H1;
ENUM_TIMEFRAMES g_InpEMA_TF = PERIOD_H1;
INPUT GROUPS |
//+------------------------------------------------------------------+
//=== Key Configuration ===
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)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 Scalping strategy EAs from our library
Pipsgrowth EX14020 Scalper
Pipsgrowth.com EX14020 AIXAUUSDScalper — AI-assisted XAUUSD scalper, full 12-layer stack.
Pipsgrowth EX10006 Momentum-Scalper
Pipsgrowth.com EX10006 USDJPY Scalper — USDJPY pullback momentum scalper, full 12-layer stack.
Pipsgrowth EX14021 Scalper
Pipsgrowth.com EX14021 EURUSDScalper — BB + MACD divergence scalper, full 12-layer stack.
Community
Educational purposes only. Do NOT use with real money. Test on demo accounts only.