EA-726 · Hedging

eq3-06 / e04lc07-v4

This EA implements a D'Alembert betting system for forex trading, managing a portfolio of currency pairs by tracking per-currency net exposure in EUR-terms. It opens positions based on exposure limits, scales in when price moves against the position (increasing lots after losses), and partially closes profitable positions. A Hamiltonian (closed-loop) currency pair set ensures net zero exposure across all value currencies.

Open the interactive view (equity curve, symbol switch)

Key facts

CategoryHedging
RiskHigh risk
Blow-up riskElevated
Rating★★☆☆☆
TypeTrading EA
TimeframesM15, H1, H4, D1
IndicatorsNone
Author—

Backtest results (H1, about 1 year)

SymbolP&LAnnualMax DDTradesWin rateSharpeRecoveryLosing streakPer tradeStatus
EURUSD0.00%0.00%0.00%0—————Not convertible yet
GBPUSD0.00%0.00%0.00%0—————Not convertible yet
USDJPY0.00%0.00%0.00%0—————Not convertible yet
XAUUSD0.00%0.00%0.00%0—————Not convertible yet

Why this EA never traded: no entry rule survived the conversion.

Converted from MQL5 to Python and run with the same rules for every EA. Positions use MT5 lot sizes (100,000 units per FX lot, 100 oz per gold lot) with 1:100 leverage, one order at a time, and a stop-out below 10% of the starting balance. Sharpe is computed from the equity curve. Results marked as unreliable are shown for completeness only.

Blow-up risk: Elevated

  • Has no stop loss or trailing stop
  • Can hold up to 3 positions at once

High: stopped out in our backtest, or martingale/grid sizing without a stop loss. Elevated: martingale or grid sizing with a stop loss, or several positions at once without a stop loss. What the label means and what we found →

Strategy analysis

This EA implements a D'Alembert betting system — decreasing stakes after wins and increasing after losses — by tracking net exposure per currency in EUR terms. Entry conditions: when no position exists for a symbol and the corresponding currency exposures are within limits, it opens a position in the direction specified by array A; when price moves adversely beyond a TP threshold, it adds to the position in LotMin increments. Exit conditions: when price moves favorably beyond a threshold, it partially closes the position (reducing to LotMin then relying on TP for final exit), or the CleanBad function forces a reduction at an acceptable loss. Position sizing uses a stepwise add/reduce approach, adding or closing LotMin lots each time, with maximum position capped by Limit_Position_Lot and maximum per-currency exposure capped by Limit_Exposure_Lot. Money management controls loss-closing pace via FreeBalance and BestBallance, with a MinMargin threshold and an emergency 123.4% margin level check. The ManageTP feature moves take-profit levels when unexpected profit occurs to lock in gains. The core strategy exploits the natural hedging property of multi-currency portfolios through a Hamiltonian set (e.g., EURUSD-EURGBP-GBPUSD triangular relationship) to maintain low net exposure, then uses the D'Alembert approach to gradually build and reduce positions during price fluctuations.

Strengths

  • Uses Hamiltonian currency pair sets for natural hedging, reducing overall net exposure risk
  • D'Alembert position sizing improves average entry price effectively during mean-reverting markets
  • Dual exposure limits (per-currency and per-symbol) effectively prevent risk concentration
  • ManageTP feature locks in gains during unexpected profits, avoiding profit giveback
  • Margin level checks and emergency threshold (123.4%) provide capital safety floor

Weaknesses

  • D'Alembert system continuously adds positions during trending markets, amplifying losses indefinitely
  • No stop-loss (SL=0), relying entirely on gradual reduction mechanism — margin call possible in extreme moves
  • Global variables I/J used across all functions create severe state coupling and reentrancy risks
  • Exposure() function assumes EUR+XXX symbols always exist for currency conversion, no error handling for missing symbols
  • Messy code structure with extensive global variables and implicit dependencies, poor readability and maintainability

Possible improvements

  • Add hard stop-loss (SL) as a last line of defense against extreme market moves to prevent margin calls
  • Refactor global variables I/J into function parameters to eliminate state coupling and reentrancy hazards
  • Add return value checks in Exposure() for SymbolInfoDouble calls to prevent division-by-zero when EUR+XXX symbols are missing

Risk assessment

Overall risk: High risk

  • No hard stop-loss (SL=0) — sustained adverse moves can lead to continuous position additions and margin call
  • D'Alembert position sizing causes exponentially growing losses during sustained trending markets
  • Global variable state coupling can produce incorrect trade orders during function reentrancy
  • Exposure() currency conversion lacks error handling — SymbolInfoDouble returning 0 causes division-by-zero

Evaluation scores

Code quality1.0
Strategy logic3.0
Risk management2.0
Robustness1.0
Innovation3.0
Documentation1.0
Overall1.8

Parameters

ParameterDefaultDescription
WARNING"NOT all Input is check to be correct !"Warning for incomplete input parameter validation
LastRiskDateD'2012.12.17 23:59:59' / D'2011.12.17 23:59:59'Risk trading deadline; switches to risk-free mode after
MinMargin200.1Minimum margin level to disallow adding positions
KTP0.0025 / 0.0095Take-profit as percentage of price (0.01=1%)
Limit_Position_Lot2.5Maximum position lot size per currency pair
Limit_Exposure_Lot1.25 / 0.55Maximum net exposure lot size per currency
LotAtRisk1.75 / 0.75Maximum acceptable exposure difference when sending orders (Val1-Val2)
InversefalseWhether to reverse all trade directions
ManageTPtrueWhether to quickly move TP on unexpected profit
ManageLOSStrueWhether to lower average entry price on loss (reduce position)
NoWorkTime9 / 0Minimum interval in seconds between executions (for faster backtesting)
LotMX3 / 10Minimum lot multiple (effective only when min lot is 0.01)
KStart7Initial opening lot multiplier (eq3-06 version only)

Similar Hedging EAs

Backtests are historical simulations and do not guarantee future results. Not financial advice.

Get the weekly Arena report

One email a week: ranking changes, new signals and new research. No spam; unsubscribe any time.