P
PipsGrowth
HedgingOpen Source – Free

Pipsgrowth EX05003 Hedge

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

Pipsgrowth.com EX05003 Tokyo Intervention Hedger — asymmetric dual-engine (SMC-long / PDL-short) hedge, full 12-layer stack.

Overview

Pipsgrowth EX05003 is an asymmetric dual-engine USDJPY hedger built around a single observation: yen pairs grind upward for weeks and then collapse in hours when the Bank of Japan talks tough or the U.S. CPI print surprises. The EA captures both sides of that pattern with two completely separate signal stacks that share an account but use independent magic numbers (InpMagicLong = 22205003 for the long engine, InpMagicShort = 22215003 for the short engine). On the long side it is a patient SMC follower that only buys when an H1 swing structure has just turned bullish, the close retests a freshly created bullish order block, and the D1 simple moving average (MA_D1_PERIOD = 50) is sloping up beneath the bid. On the short side it is a volatility-event hunter that only sells when the bid is above the user-defined intervention zone (InpInterventionLevel, default 150.0 — a price that corresponds to a typical USDJPY level the BoJ has historically defended) and the previous daily low (g_prevDayLow, refreshed each new bar from iLow(_Symbol, PERIOD_D1, 1)) has just been broken. The two engines never blend into a single basket: each is sized, stopped, trailed, and partial-taken by its own function set (ManageLongPositions, ManageShortPositions) and the two g_blockReason strings (e.g. CAP_BELOW_FLOOR, DAILY_LOSS, MARGIN) are tracked independently so you can see at a glance which leg tripped a guard.

The regime layer that gates both engines is a seven-state classifier built from three indicators on the chart timeframe — ADX(14) via g_hADX, a 20-period/2.0-deviation Bollinger Band via g_hBB, and a 14-period ATR via g_hATR — combined with an H1 ADX mirror (g_hADX_H1) and the daily 50-MA. The UpdateRegime() function reads ADX bar 1, computes an ATR-to-close percent and a Bollinger band width proxy, then runs an ATR-percentile rank over a 100-bar lookback (ATRPCT_LOOKBACK) before resolving the state. The long engine refuses to seed in REG_CHOPPY, while the short engine additionally refuses to seed in REG_COMPRESS and REG_RANGE — shorts need volatility to confirm a PDL break is a real event, not a thin-session poke. STRONG_TREND (ADX ≥ 30) and WEAK_TREND (ADX ≥ 18) add 20 confidence points to the long signal, and BREAKOUT / EXPAND add 20 to the short signal. CHOPPY is a hard refusal for both sides, which is what keeps the EA from getting chopped up during Tokyo's pre-open drift.

Entries are driven by LongSignal() and ShortSignal(). LongSignal returns +1 only when bid is above the D1 MA(50), the H1 swing trend (g_swingTrend) is BULLISH, the last closed bar on the chart timeframe was a bullish candle (close > open), and the low of that bar touched an active bullish order block (OBTouch(BULLISH, low1)). Order blocks themselves are built by CreateOrderBlock(bias, refBar), which walks back up to MAX_OB_LOOKBACK = 10 H1 bars from the swing pivot, picks the first candle whose body runs in the direction of the bias (a bearish candle for a bullish OB, a bullish candle for a bearish OB), and records its high and low. There are at most MAX_OB_COUNT = 5 OBs in the ring buffer; the oldest is shifted out when a sixth is added. CheckOBMitigation() deactivates a bullish OB the moment the H1 low closes below its bottom (and a bearish OB the moment the H1 high closes above its top), and ExpireOldOBs() retires anything older than MAX_OB_AGE_BARS = 100 H1 bars. The combination of mitigation + expiry + retest is what makes the long engine selective: the same OB can only trigger once, and only inside its 100-bar window.

ShortSignal returns -1 only when bid ≥ InpInterventionLevel, g_prevDayLow is populated, and the last closed chart bar has either its close or low below g_prevDayLow. Confidence starts at 65 and climbs another 20 in BREAKOUT or EXPAND regimes, 10 if ATR-percent is above 0.5 (intervention-grade volatility), and 5 if the H1 swing structure is already bearish. That asymmetry is intentional: shorts into a PDL break during intervention-grade volatility are the only short signal worth taking, and the regime and confidence stacking makes the trade conditional on actual expansion. Once both ConfirmLong / ConfirmShort pass — ConfirmLong requires a non-CHOPPY regime, the HTF gate, and a valid R:R (MIN_RR_RATIO = 1.0 enforced via InpRR_Long / InpRR_Short); ConfirmShort requires non-COMPRESS, non-RANGE, non-CHOPPY, and a valid R:R — the EA sizes the order in CalcLot(slDistance, effectiveCap) against ATR-based stop distance, applying a hard ceiling at InpMaxLot (default 5.0 lots) and normalizing to the broker's volume step. Margin is pre-checked via OrderCalcMargin and refused if the new order would eat more than 80 percent of the free margin.

Management is where the two engines really diverge. Long stops sit 2.5 × ATR(14) below entry (InpSLATR_Long) — deliberately wide because USDJPY spikes 30-50 pips on every BoJ rumor and a tight stop would die on noise. Short stops sit 1.5 × ATR(14) above entry (InpSLATR_Short) — deliberately tight because once a PDL breaks during intervention, the move is fast and the EA wants to be wrong small rather than wrong by a hundred pips. Long R:R is 1.5 (InpRR_Long), short R:R is 3.0 (InpRR_Short), which means the short side is a 1:3 setup on a 1.5-ATR stop, the long side a 1:1.5 on a 2.5-ATR stop. Once profit exceeds TRAIL_ACTIVATE_ATR = 1.0 × ATR the stop is ratcheted to entry plus BE_BUFFER_POINTS = 10 points (break-even) one-shot, and a 50 percent partial is taken at TP1 (PARTIAL_TP_FRACTION = 0.5) provided the residual volume is at least 1.5 × the broker's minimum lot. After break-even, the stop is trailed at InpTrailATR = 1.5 × ATR(14) using the H1 ATR for longs and the chart-timeframe ATR for shorts, and any time the swing trend flips against the position the EA closes it via TryClose_EX05003 (3 retries at 200 ms each on REQUOTE / TIMEOUT / PRICE_OFF / PRICE_CHANGED). Friday 20:00 server time triggers CloseAllByMagic for both magics if InpCloseFriday is on, so no trade survives the weekend gap.

The hardening layer is the same safety stack the rest of the EX05 hedge family runs. Effective capital is min(InpCapAmount, equity) when a cap is configured, plain equity otherwise, and EffectiveCapitalNet() subtracts the day's realized PnL across both magics so the lot calculator sees the actual headroom. Daily loss limit is InpDailyLossLimitPct = 3 percent of effective capital, and the weekly gate is twice that. InpMaxConsecLosses = 3 losses arms a 30-minute cooldown (g_cooldownUntil), which is enforced in IsSafeToTrade along with the per-day trade cap (InpMaxTradesPerDay = 50), the capital floor (InpCapFloor = $50 by default — any equity below this blocks new entries), the 95 percent minimum equity floor (InpMinEquityPercent), and the IsMarketOpen / InActiveSession / IsNewsTime gates. The session filter is GMT-aware via DetectGMTOffset, which walks back up to 100 H1 bars looking for the first weekend gap > 2 hours and infers the server's offset from there. With InpAvoidAsia left at false (the default — this is a Tokyo EA, not an anti-Tokyo EA) it accepts Tokyo 0-9 broker time, plus London 7-16 GMT and New York 12-21 GMT. Order entry is 3 retries on REQUOTE / PRICE_OFF / PRICE_CHANGED, 100 ms apart; SLs are clamped to the broker's stop level plus the BE buffer via ClampSLForBuy / ClampSLForSell, and the OnTester custom criterion is (net × profit factor) / (1 + max DD) with a 30-trade minimum. The dashboard Comment() prints regime, ADX, ATR%, BB width, and the current block reason on every tick.

In backtest, expect the long engine to take the majority of trades during sustained D1 uptrends in USDJPY, with most of the PnL coming from the 50 percent partial + trailing stop on those longer swings. The short engine will be quieter — Tokyo intervention breaks are rare, and the regime + confidence + intervention-level gates mean a typical year might produce only a handful of short seeds, each with a tight 1.5-ATR stop and a 3R target. Drawdown profiles of the two engines are independent, which is the point: a short that catches a BoJ surprise can print more in one trade than the long engine prints in a month, and the long engine's wider 2.5-ATR stop is the cost of staying in the trade long enough to give the trailing stop room to work. The two magic numbers make it straightforward to run the long engine and the short engine on different charts of the same account, or to disable one side entirely (InpEnableLongs / InpEnableShorts) when the user wants to convert the EA into a pure SMC long-only or a pure intervention-short specialist.

Strategy Deep Dive

The OnTick loop starts by running ManageLongPositions and ManageShortPositions, which independently walk their own magic-number sets and apply BE / 50% partial / 1.5 × ATR trail / regime-or-swing-flip exit before anything else gets a chance to run. If InpCloseFriday is on and the broker clock has crossed Friday 20:00, CloseAllByMagic flushes both sides. On a new H1 bar, UpdateSwingStructure looks 10 bars back on either side of the H1 pivot, marks swing highs and lows into g_swingHighPrice / g_swingLowPrice, and calls CreateOrderBlock to stamp a new OB (max 5, ring-buffered) whose body is the last opposing candle inside the lookback; CheckOBMitigation and ExpireOldOBs then deactivate invalidated or 100-bar-stale OBs. IsSafeToTrade bundles the capital floor, 95% equity floor, daily 3% / weekly 6% loss limits, consec-loss cooldown, 50-trade-per-day cap, market-open check, and (optionally) the news filter before the new-bar entry path is allowed to continue. On a new chart-TF bar, UpdateRegime builds the seven-state classifier from ADX(14), Bollinger(20, 2.0) width, and a 100-bar ATR-percentile rank; UpdateDailyLevels refreshes g_prevDayHigh / g_prevDayLow from D1. The no-trade gate then runs DDExceeded (25% peak-to-trough), SpreadOK (15-point cap), InSession (Tokyo 0-9 broker time, with London/NY stacks), NewsBlackout (BoJ 03:00 ±30 min, US CPI 12:00 ±30 min), and FridayCutoff; on a pass, ProcessLongEntry and ProcessShortEntry independently call LongSignal / ShortSignal, apply the matching Confirm, compute ATR-based SL × R:R, run CalcLot, check MarginOK, and dispatch SendBuy / SendSell with 3 retries on REQUOTE / PRICE_OFF / PRICE_CHANGED before writing the bar-time guard and the last-trade timestamp. The OnTester criterion is (net × profit factor) / (1 + max DD) with a 30-trade minimum, and the dashboard Comment() prints regime, ADX, ATR%, BB width and the current g_blockReason on every tick.

Entry Signal

Long entries fire on a closed chart bar when bid sits above the D1 SMA(50), the H1 swing trend is BULLISH, the bar closed bullish (close > open), and its low touched an active bullish SMC order block built from the last H1 swing pivot — confidence starts at 60 and adds 20 in a trending regime, 10 if ADX ≥ 25, and 10 if ATR-percent exceeds 0.3. Short entries fire when bid ≥ InpInterventionLevel (default 150.0), g_prevDayLow is populated, and the last closed bar broke below the previous day's low (close or low under PDL) — confidence starts at 65, adds 20 in BREAKOUT/EXPAND regimes, 10 in intervention-grade volatility (ATR% > 0.5), and 5 if the H1 swing structure is already bearish. Both engines are gated by independent magic numbers (InpMagicLong 22205003 / InpMagicShort 22215003), a 15-point spread cap, 1-position-per-side, a 5-minute cooldown, a per-bar duplicate guard, and a capital floor of $50.

Exit Signal

Exits are managed by ManageLongPositions and ManageShortPositions, each scanning only its own magic. Once a trade is in profit by ≥ 1.0 × ATR the stop is ratcheted to entry + 10 points (BE) one-shot, then a 50 percent partial is taken at TP1 if the residual volume clears 1.5 × the broker's minimum lot, and the stop is then trailed at 1.5 × ATR behind the bid (using H1 ATR for longs, current-TF ATR for shorts). Any time the H1 swing trend flips against the position — or the regime goes CHOPPY for a long, or a non-EXPAND regime for a short — the EA closes the position with TryClose_EX05003 (3 retries at 200 ms on REQUOTE / TIMEOUT / PRICE_OFF / PRICE_CHANGED). Friday 20:00 server time triggers CloseAllByMagic for both magics if InpCloseFriday is on.

Stop Loss

Long stops are placed 2.5 × ATR(14) below entry via InpSLATR_Long (the wider setting absorbs the 30-50 pip spikes that come with every BoJ rumor); short stops are placed 1.5 × ATR(14) above entry via InpSLATR_Short (the tighter setting keeps a PDL-breakout loss small). All stops are clamped to the broker's stop level plus the 10-point BE buffer by ClampSLForBuy / ClampSLForSell, and the lot size is computed in CalcLot against the ATR-based stop distance so a hit to the SL always equals the user-defined 0.5 percent risk of effective capital.

Take Profit

Long targets use R:R = 1.5 (InpRR_Long) from a 2.5 × ATR stop — i.e. 3.75 × ATR from entry; short targets use R:R = 3.0 (InpRR_Short) from a 1.5 × ATR stop — i.e. 4.5 × ATR from entry. The TP is set on the order ticket at entry, a 50 percent partial is taken at the TP1 midpoint, and the remaining 50 percent rides the 1.5 × ATR trailing stop until it gets hit or the position is force-closed by regime/swing-flip / Friday cutoff.

Best For

Minimum recommended balance: $100 (HIGH risk tag), USDJPY H1 chart, on an ECN or low-spread broker that lets you set the dealer's intervention level and that can carry the wider 2.5 × ATR long stop without the broker's stop-level truncating it. The EA's natural time window is the Tokyo session (broker hours 0-9) for the long-engine OB retests, with the short engine wired to wake up on any PDL break where the bid is above the user-defined InpInterventionLevel (default 150.0). Friday 20:00 server cutoff means the EA is not for traders who want to hold through the weekend, and the 3-consecutive-losses → 30-minute cooldown means the EA will flatten itself quickly in choppy regimes rather than ride them out. Best fit: traders who already understand yen intervention mechanics and want a single EA that does the OB retest grind on one magic and the volatility-breakout countertrade on another, with the option to disable either side via InpEnableLongs / InpEnableShorts.

Strategy Logic

Pipsgrowth EX05003 Hedge — Strategy Logic Analysis (from .mq5 source)

Family: Hedge Magic: Long=22205003, Version: 2.00

BRIEF: "Slow up, fast down" USDJPY asymmetry. LONG engine = H1 SMC Order-Block retest + D1 MA50 uptrend. SHORT engine = Previous-Day-Low volatility breakout while price in intervention zone (>= 150). 12 layers: REGIME, SIGNAL, ENTRY, CONFIRM, NO-TRADE, CAPITAL CAP, RISK, SIZING, MANAGE, EXIT, SCALING, OnTester

INDICATOR STACK:

  • ATR
  • ATR_H1
  • MA_D1
  • ADX
  • BB
  • ADX_H1

KEY FUNCTIONS:

  • StopLevelPrice()
  • NormLot()
  • NormPrice()
  • EffectiveCapital()
  • RealizedTodayMagic()
  • EffectiveCapitalNet()
  • CalcLot()
  • DailyLossExceeded()
  • UpdateRegime()
  • UpdateSwingStructure()
  • CreateOrderBlock()
  • CheckOBMitigation()
  • ...and 39 more

INTERNAL CONSTANTS (24 total):

  • ATR_PERIOD = 14 // ATR period (current TF + H1)
  • MA_D1_PERIOD = 50 // Daily trend MA
  • SWING_LENGTH = 10 // SMC pivot swing length (H1)
  • MAX_OB_COUNT = 5 // Max tracked order blocks
  • MAX_OB_AGE_BARS = 100 // OB expiry (H1 bars)
  • TOKYO_START_HOUR = 0 // Tokyo session start (broker GMT)
  • TOKYO_END_HOUR = 9 // Tokyo session end
  • NEWS_HOUR_BOJ = 3 // BoJ presser window
  • NEWS_HOUR_CPI = 12 // US CPI window
  • NEWS_BLACKOUT_MIN = 30 // News blackout minutes each side
  • TRADE_COOLDOWN_MIN = 5 // Cooldown between trades (minutes)
  • FRIDAY_CUTOFF_HOUR = 20 // No new trades after Friday 20:00
  • MAX_TRADE_RETRIES = 3 // Order send retries
  • BE_BUFFER_POINTS = 10 // Break-even buffer (points)
  • TRAIL_ACTIVATE_ATR = 1.0 // Trail activation (x ATR profit)
  • ...and 9 more

INPUT PARAMETERS (33 total across 7 groups):

  • [=== Identity ===] InpMagicLong = 22205003 // Magic — Long engine (unique)
  • [=== Identity ===] InpMagicShort = 22215003 // Magic — Short engine (unique)
  • [=== Identity ===] InpTradeComment = "Psgrowth.com Expert_05003" // Trade comment
  • [=== Risk & Sizing ===] InpRiskPercent = 0.5 // Risk per trade (% of effective capital)
  • [=== Risk & Sizing ===] InpDailyLossLimitPct = 3.0 // Daily loss limit (% of effective capital)
  • [=== Risk & Sizing ===] InpMaxLot = 5.0 // Hard lot cap per trade
  • [=== Risk & Sizing ===] InpMaxPerSide = 1 // Max concurrent positions per side
  • [=== Risk & Sizing ===] InpSLATR_Long = 2.5 // Long SL distance (x ATR) — wider for JPY spikes
  • [=== Risk & Sizing ===] InpSLATR_Short = 1.5 // Short SL distance (x ATR) — tight for crash exit
  • [=== Capital Allocation Cap ===] InpCapAmount = 0.0 // Cap amount (real money $, not leveraged)
  • [=== Capital Allocation Cap ===] InpCapFloor = 50.0 // Floor below which new entries blocked ($)
  • [=== Signal ===] InpEnableLongs = true // Enable long (SMC) engine
  • [=== Signal ===] InpEnableShorts = true // Enable short (PDL-breakout) engine
  • [=== Signal ===] InpInterventionLevel = 150.0 // Intervention zone price floor (shorts only)
  • [=== Regime & Confirm ===] InpMaxSpread = 15 // Max spread (points)
  • [=== Regime & Confirm ===] InpRR_Long = 1.5 // Long R:R minimum
  • [=== Regime & Confirm ===] InpRR_Short = 3.0 // Short R:R minimum
  • [=== Exit & Manage ===] InpTrailATR = 1.5 // ATR trailing distance (x ATR)
  • [=== Exit & Manage ===] InpCloseFriday = true // Close positions before weekend
  • [=== Hardening: GMT Sessions ===] InpServerGMTOffset = 0 // Server GMT offset hours (0=auto-detect)
  • [=== Hardening: GMT Sessions ===] InpLondonStartHour = 7 // London session start (GMT)
  • [=== Hardening: GMT Sessions ===] InpLondonEndHour = 16 // London session end (GMT)
  • [=== Hardening: GMT Sessions ===] InpNYStartHour = 12 // New York session start (GMT)
  • [=== Hardening: GMT Sessions ===] InpNYEndHour = 21 // New York session end (GMT)
  • [=== Hardening: GMT Sessions ===] InpAvoidAsia = false // Avoid Asian session (Tokyo EA needs Asia)
  • [=== Hardening: GMT Sessions ===] InpAsiaStartHour = 0 // Asian session start (GMT)
  • [=== Hardening: GMT Sessions ===] InpAsiaEndHour = 7 // Asian session end (GMT)
  • [=== Hardening: GMT Sessions ===] InpNewsFilter = false // Avoid trading near news session opens
  • [=== Hardening: GMT Sessions ===] InpNewsFilterMinutes = 15 // Minutes to avoid around news
  • [=== Hardening: GMT Sessions ===] InpMaxTradesPerDay = 50 // Maximum trades per day
  • [=== Hardening: GMT Sessions ===] InpMinEquityPercent = 95.0 // Stop trading if equity < this % of initial balance
  • [=== Hardening: GMT Sessions ===] InpCooldownMinutes = 30 // Cooldown minutes after consec losses
  • [=== Hardening: GMT Sessions ===] InpMaxConsecLosses = 3 // Max consecutive losses before cooldown
Pseudocode
// Pipsgrowth EX05003 Hedge — Execution Flow (from source analysis)
// Family: Hedge
// "Slow up, fast down" USDJPY asymmetry. LONG engine = H1 SMC Order-Block retest + D1 MA50 uptrend. SHORT engine = Previous-Day-Low volatility breakout while price in intervention zone (>= 150). 12 layers: REGIME, SIGNAL, ENTRY, CONFIRM, NO-TRADE, CAPITAL CAP, RISK, SIZING, MANAGE, EXIT, SCALING, OnTester

ON_INIT:
    Create indicator handles: ATR, ATR_H1, MA_D1, ADX, BB, ADX_H1
    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:
H1M15H4

How to Install This EA on MT5

  1. 1Download the .mq5 file using the button above
  2. 2Confirm your broker allows hedging (holding opposing positions simultaneously)
  3. 3Open MetaTrader 5 on your computer
  4. 4Click File → Open Data Folder in the top menu
  5. 5Navigate to MQL5 → Experts and paste the .mq5 file there
  6. 6In MT5, right-click Expert Advisors in the Navigator panel → Refresh
  7. 7Drag the EA onto a chart and configure hedge trigger level and max exposure
  8. 8Enable Allow Algo Trading and click OK

EA Parameters

ParameterDefaultDescription
InpMagicLong22205003Magic — Long engine (unique)
InpMagicShort22215003Magic — Short engine (unique)
InpTradeComment"Psgrowth.com Expert_05003"Trade comment
InpRiskPercent0.5Risk per trade (% of effective capital)
InpDailyLossLimitPct3.0Daily loss limit (% of effective capital)
InpMaxLot5.0Hard lot cap per trade
InpMaxPerSide1Max concurrent positions per side
InpSLATR_Long2.5Long SL distance (x ATR) — wider for JPY spikes
InpSLATR_Short1.5Short SL distance (x ATR) — tight for crash exit
InpCapAmount0.0Cap amount (real money $, not leveraged)
InpCapFloor50.0Floor below which new entries blocked ($)
InpEnableLongstrueEnable long (SMC) engine
InpEnableShortstrueEnable short (PDL-breakout) engine
InpInterventionLevel150.0Intervention zone price floor (shorts only)
InpMaxSpread15Max spread (points)
InpRR_Long1.5Long R:R minimum
InpRR_Short3.0Short R:R minimum
InpTrailATR1.5ATR trailing distance (x ATR)
InpCloseFridaytrueClose positions before weekend
InpServerGMTOffset0Server GMT offset hours (0=auto-detect)
InpLondonStartHour7London session start (GMT)
InpLondonEndHour16London session end (GMT)
InpNYStartHour12New York session start (GMT)
InpNYEndHour21New York session end (GMT)
InpAvoidAsiafalseAvoid Asian session (Tokyo EA needs Asia)
InpAsiaStartHour0Asian session start (GMT)
InpAsiaEndHour7Asian session end (GMT)
InpNewsFilterfalseAvoid trading near news session opens
InpNewsFilterMinutes15Minutes to avoid around news
InpMaxTradesPerDay50Maximum trades per day
InpMinEquityPercent95.0Stop trading if equity < this % of initial balance
InpCooldownMinutes30Cooldown minutes after consec losses
InpMaxConsecLosses3Max consecutive losses before cooldown
Source Code (.mq5)Open Source
Pipsgrowth_com_EX05003.mq5
#property copyright "Pipsgrowth.com"
#property link      "https://pipsgrowth.com"
#property version   "2.00"
#property strict
#property description "Pipsgrowth.com EX05003 Tokyo Intervention Hedger — asymmetric dual-engine (SMC-long / PDL-short) hedge, 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>

//+------------------------------------------------------------------+
//| CONSTANTS (non-tunable; tunables live in inputs)                  |
//+------------------------------------------------------------------+
#define BULLISH   1
#define BEARISH  -1
#define NEUTRAL   0

#define ATR_PERIOD          14        // ATR period (current TF + H1)
#define MA_D1_PERIOD        50        // Daily trend MA
#define SWING_LENGTH        10        // SMC pivot swing length (H1)
#define MAX_OB_COUNT        5         // Max tracked order blocks
#define MAX_OB_AGE_BARS     100       // OB expiry (H1 bars)
#define TOKYO_START_HOUR    0         // Tokyo session start (broker GMT)
#define TOKYO_END_HOUR      9         // Tokyo session end
#define NEWS_HOUR_BOJ       3         // BoJ presser window
#define NEWS_HOUR_CPI       12        // US CPI window
#define NEWS_BLACKOUT_MIN   30        // News blackout minutes each side
#define TRADE_COOLDOWN_MIN  5         // Cooldown between trades (minutes)
#define FRIDAY_CUTOFF_HOUR  20        // No new trades after Friday 20:00
#define MAX_TRADE_RETRIES   3         // Order send retries
#define BE_BUFFER_POINTS    10        // Break-even buffer (points)
#define TRAIL_ACTIVATE_ATR  1.0       // Trail activation (x ATR profit)
#define PARTIAL_TP_FRACTION 0.5       // Partial TP @ TP1 (fraction)
#define MIN_RR_RATIO        1.0       // Minimum R:R gate
#define ADX_THRESHOLD       18.0      // Regime ADX floor
#define ATRPCT_LOOKBACK     100       // ATR-percentile lookback
#define BB_PERIOD           20        // Bollinger period
#define BB_DEV              2.0       // Bollinger deviation
#define HTF_TF              PERIOD_H1 // Higher-timeframe for confirm
#define MAX_OB_LOOKBACK     10        // Max bars scanned for OB body
#define MIN_TRADES_TESTER   30        // OnTester min trades

//+------------------------------------------------------------------+
//| ENUMS                                                             |
//+------------------------------------------------------------------+
enum ENUM_REGIME
{
   REG_STRONG_TREND,
   REG_WEAK_TREND,
   REG_RANGE,
   REG_BREAKOUT,
   REG_COMPRESS,
   REG_EXPAND,
   REG_CHOPPY
};

//+------------------------------------------------------------------+

Full source code available on download

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

Tags:ex05003hedgepipsgrowthfreemt5usdjpy

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_EX05003.mq5
File Size47.0 KB
Versionv2.00
PlatformMetaTrader 5
File Type.mq5 Source
StrategyHedging
Risk LevelHigh Risk
Timeframes
H1M15H4
Currency Pairs
USDJPY
Min. Deposit$100