SuperTrande Hedge EA
- Experts
-
Sandip R Pawar
Professional software developer since 2007 turned full-time algorithmic trader. Specializing in custom automated infrastructure, data-driven market strategies, and precision execution across derivatives, XAUUSD, and crypto. - Version: 1.0
SuperTrend Hedge EA: Precision XAUUSD M1 Trend Engine with Instant Pullback Hedging & Prop-Grade Equity Protection
========================================================================
SUPERTREND HEDGE EA (v1.00) — XAUUSD M1 to any MULTI-TIMEFRAME SYSTEM
========================================================================
SuperTrend Pro Hedge EA is a precision-engineered automated trading system built specifically for Gold (XAUUSD) on the M1 timeframe. Unlike dangerous grid or martingale bots that blow accounts during prolonged trends, SuperTrend Pro Hedge EA combines a responsive Supertrend breakout core with a 4-Mode Dynamic Higher-Timeframe EMA Filter, a Dual-Magic Instant Hedge (H-Order) engine, automated Partial Close, multi-stage Trailing Stop, and a hard Peak Balance Drawdown Breaker.
✔ NO Martingale
✔ NO Grid or Averaging Down
✔ Strict Fixed-Lot Execution with Independent Base & Hedge Magic Numbers
✔ Built-In On-Chart Historical Replay & Signal Audit Dashboard
✔ Hard USD Peak-to-Valley Equity Cap with Automatic Cooldown Timer
========================================================================
1. CORE ARCHITECTURE: HOW THE DUAL BASE + INSTANT HEDGE ENGINE WORKS
========================================================================
Every valid trend flip on XAUUSD M1 is filtered before execution and managed through two independent order streams using dedicated Magic Numbers:
A) THE BASE ORDER (Magic #123456) — Trend Rider
• Opens in the direction of the confirmed Supertrend + MTF EMA signal.
• Automated Partial Close: Automatically closes 50% of the position volume at +1,000 points profit (when Base Lot >= 0.02), banking immediate realized gains.
• Smart Trailing Stop: Once price reaches +4,000 points profit, the trailing stop activates at a 2,000-point distance with a 1,000-point minimum step.
• Extended Trend Target: Holds the runner up to the +10,000 points Take Profit target or until an opposite confirmed signal flips the trend.
B) THE INSTANT HEDGE "H-ORDER" (Magic #123457) — Pullback Monetizer
• Immediately upon opening the Base Order, the EA fires a paired opposite Hedge Order (H-Order).
• Independent Risk-to-Reward: Configured by default with a tight 500-point Stop Loss and a 2.0x Take Profit Multiplier (+1,000 points target).
• Why It Works on Gold (XAUUSD): M1 breakouts on Gold frequently experience an initial liquidity sweep or pullback before continuing the macro trend—or occasionally snap back during fakeouts.
- Scenario 1 (Dip & Rally): Price dips 1,000 points first -> Hedge TP hits (+1,000 pts banked), and then price rallies to hit Base Partial Close (+1,000 pts) and Base Trailing/TP!
- Scenario 2 (Immediate Breakout): Price rockets straight in the Base direction -> Base Partial Close (+1,000 pts) + Base Trailing/TP easily outpace the small 500-point Hedge SL.
- Scenario 3 (Sudden Fakeout Reversal): If the breakout fails immediately, the Hedge Order captures +1,000 points in the opposite direction to offset Base drawdown.
========================================================================
2. 4-MODE DYNAMIC MULTI-TIMEFRAME EMA FILTER
========================================================================
Standard Supertrend EAs get chopped up in sideways markets. SuperTrend Pro Hedge EA solves this with a synchronous EMA(50) engine offering 4 selectable evaluation modes:
1. EMA_FILTER_DYNAMIC_MTF (Default - Mode 0):
Requires simultaneous alignment of the Live Higher-Timeframe (D1) EMA(50) AND the Chart Timeframe (M1) EMA(50) + positive/negative EMA slope. Delivers maximum protection against counter-trend whipsaws.
2. EMA_FILTER_CHART_TF (Mode 1):
Evaluates M1 Close vs M1 EMA(50) along with current M1 EMA slope direction for faster intraday responsiveness.
3. EMA_FILTER_HTF_LIVE (Mode 2):
Computes the real-time synchronous HTF (D1) EMA(50) on every M1 bar close and checks live HTF EMA slope.
4. EMA_FILTER_HTF_CLOSED_BAR (Mode 3):
Classic institutional filter comparing the last completed Higher-Timeframe bar close against the completed HTF EMA(50).
========================================================================
3. PROP-FIRM GRADE PEAK DRAWDOWN CAP & COOLDOWN PROTECTION
========================================================================
Capital preservation is hard-coded into every tick:
• High-Water Mark Tracking: The EA continuously tracks your highest achieved Account Balance (Peak Balance).
• Hard USD Drawdown Limit (Default: $150): If either Floating Equity or Account Balance drops by $150 from the Peak Balance, Cap Protection triggers immediately.
• Emergency Liquidation: All open Base and Hedge orders are closed instantly.
• Flexible Recovery Mode:
- Cooldown Mode (Default: 5 Days): Pauses all new trading for 5 full days to let abnormal market conditions pass, then automatically resets the Peak Balance and resumes trading.
- Permanent Stop Mode: Halts the EA permanently until manually reset by the trader.
========================================================================
4. BUILT-IN ON-CHART HISTORICAL REPLAY & AUDIT DASHBOARD
========================================================================
When enabled (InpShowHistoricalDashboard = true), the EA renders a comprehensive real-time analytical table directly on your chart:
• Displays Total Raw Supertrend Signals vs Signals Blocked by EMA(50) vs Allowed Signals.
• Simulates historical Base, Partial Close, and Hedge trades across up to 20,000 bars including spread, Peak Drawdown Cap, and Cooldown periods.
• Shows exact Entry/Exit timestamps, Entry Bar OHLC, active EMA values, Win/Loss count, and Net P/L.
========================================================================
5. INPUT PARAMETERS GUIDE
========================================================================
[Single Chart Settings]
• InpOnlyAssignedChart (true): Restricts live execution to the designated symbol/timeframe.
• InpSymbol ("XAUUSD"): Target trading instrument.
• InpTimeframe (PERIOD_M1): Working chart timeframe.
[Supertrend Core Settings]
• InpATRPeriod (14): ATR period for Supertrend calculation.
• InpATRMultiplier (0.07): ATR band multiplier optimized for M1 Gold momentum.
• InpLotSize (0.01): Base order volume (use >= 0.02 lots to enable 50% live partial close on 0.01 step brokers).
• InpSlippage (3): Maximum price deviation in points.
• InpCloseOpposite (true): Automatically closes opposite Base & paired Hedge positions on a confirmed signal flip.
• InpUseBarOpenForSLTP (false): False uses exact real Ask/Bid execution price for SL/TP calculation.
[Money Management Settings]
• InpStopLoss (0.0): Base order Stop Loss in points (0 = managed by Opposite Signal & Cap Drawdown Protection).
• InpTakeProfit (10000.0): Base order Take Profit in points.
• InpBotComment ("Super Trend"): Custom trade comment.
[Partial Close Settings — Base Orders]
• InpEnablePartialClose (true): Enables automatic partial profit taking.
• InpPartialCloseProfitPoints (1000.0): Profit threshold in points to trigger partial close.
• InpPartialClosePercent (50.0): Percentage of Base volume to close.
• InpOnlyOnePartialClose (true): Ensures partial close executes only once per position ID.
[Trailing Stop Settings — Base Orders]
• InpEnableTrailingStop (true): Enables dynamic trailing stop on Base orders.
• InpTrailingActivatePoints (4000.0): Profit in points required to activate trailing.
• InpTrailingDistancePoints (2000.0): Trailing stop distance behind current price in points.
• InpTrailingStepPoints (1000.0): Minimum favorable step in points before modifying SL.
[Trade Direction & Signal Mode]
• InpSignalMode (SIGNAL_MODE_NORMAL): Choose Normal signals or Flipped (reverse) signals.
[Max Orders Settings]
• InpMaxOrders (1): Maximum simultaneous Base setups.
• InpMaxTotalLot (10.0): Maximum combined lot exposure (Base + Hedge).
[Higher Timeframe & EMA Trend Filter]
• InpEnableHTFFilter (true): Activates the EMA trend filter.
• InpHTFTf (PERIOD_D1): Higher timeframe for macro trend calculation.
• InpHTFEMA (50): EMA period.
• InpEMAFilterMode (EMA_FILTER_DYNAMIC_MTF): Select between the 4 EMA evaluation modes.
[Cap Drawdown & Cooldown/Permanent Settings]
• InpEnableCapProtection (true): Enables Peak Balance drawdown guard.
• InpCapDrawdownUSD (150.0): Maximum allowed drawdown in USD from Peak Balance.
• InpPermanentStopOnCap (false): False = use Cooldown Days; True = permanent halt on breach.
• InpCooldownDays (5): Number of days to pause trading after a Cap Drawdown trigger.
[Hedge (H-Order) Settings]
• InpEnableHedge (true): Opens an instant opposite Hedge order alongside every Base order.
• InpHedgeSLPoints (500.0): Hedge Stop Loss in points.
• InpHedgeTPMultiplier (2.0): Hedge Take Profit multiplier relative to Hedge SL (500 x 2.0 = 1,000 points).
• InpHedgeLotMultiplier (1.0): Hedge lot size multiplier relative to InpLotSize.
• InpShowHedgeInTable (false): Show/hide Hedge trades inside the on-chart replay table.
========================================================================
6. RECOMMENDED SETUP & REQUIREMENTS
========================================================================
• Symbol: XAUUSD (Gold)
• Timeframe: M1 (1-Minute Chart)
• Account Type: Hedging Account (Required — Netting accounts cannot hold simultaneous Base + Hedge positions)
• Broker: ECN / Raw Spread broker with low XAUUSD spreads
• Minimum Deposit: $300 - $500+ for 0.01 lot (or $500 - $1,000+ when using 0.02 lot to utilize 50% live partial close)
• VPS: Low-latency VPS (less than 20ms ping) is strongly recommended for 24/5 tick-level partial close, trailing stop, and equity cap monitoring.
