Lock
This EA implements a locking/hedging strategy by opening opposing positions on the same instrument to protect existing trades from adverse market moves. It manages locked positions and unlocks them when market conditions become favorable. The core logic revolves around opening a reverse trade to offset risk on an existing position, effectively creating a synthetic flat state until a directional decision is made.
Open the interactive view (equity curve, symbol switch)Key facts
Backtest results (H1, about 1 year)
| Symbol | P&L | Annual | Max DD | Trades | Win rate | Sharpe | Recovery | Losing streak | Per trade | Status |
|---|---|---|---|---|---|---|---|---|---|---|
| EURUSD | -2.78% | -2.42% | 4.09% | 114 | 46.90% | -0.63 | -0.68 | 5 | −$2.16 | Reliable |
| GBPUSD | -0.24% | -0.21% | 4.21% | 116 | 47.00% | -0.01 | -0.06 | 8 | $0.00 | Reliable |
| USDJPY | -4.43% | -3.86% | 7.04% | 113 | 42.90% | -0.81 | -0.63 | 10 | −$4.09 | Reliable |
| XAUUSD | +11.32% | +9.26% | 52.86% | 111 | 50.00% | 0.48 | 0.21 | 7 | +$12.54 | Reliable |
Profitable on 1 of 4 markets with reliable results.
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.
Month by month
| Market | Months with a gain | Best month | Worst month |
|---|---|---|---|
| EURUSD | 38% | +1.57% 2026-04 | -1.36% 2026-01 |
| GBPUSD | 46% | +1.31% 2026-08 | -2.71% 2026-10 |
| USDJPY | 46% | +2.56% 2026-04 | -4.65% 2026-08 |
| XAUUSD | 54% | +48.49% 2026-02 | -28.34% 2026-08 |
From the backtest equity curve, sampled about every two days; only reliable results.
Blow-up risk: No blow-up pattern found
- Can hold up to 2 positions at once
On its own this is not a typical blow-up pattern, and the account was not stopped out in our backtests. That is not a guarantee: any EA can lose money.
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
The core concept of the lock strategy is to freeze floating profit or loss by opening an opposing position on the same instrument, bringing the net exposure on that symbol close to zero. Entry conditions are typically triggered when an existing position shows adverse floating movement reaching a preset loss threshold, at which point a reverse locking order is placed, or profit is proactively locked when specific market signals appear. Exit conditions rely on unlock logic — when the market trend reasserts itself or technical indicators confirm a direction, the losing side position is closed while the profitable side is retained. In terms of position sizing, the lock order lot size usually matches the original position to achieve a full hedge, though some lock strategies use proportional locking. For money management, since both long and short positions are held simultaneously, the margin requirement doubles, demanding higher account capital. The strategy's risk lies in improper unlock timing potentially causing losses on both sides, and prolonged locked positions consume significant margin, reducing capital efficiency.
Strengths
- Effectively freezes existing floating profit, preventing profit giveback
- Provides protection during uncertain market direction, avoiding the frustration of being stopped out before reversal
- Compared to direct stop-loss closing, locking retains the opportunity for profit on both sides
Weaknesses
- Margin requirement doubles, demanding high account capital and risking margin call forced liquidation
- Unlock timing is difficult to judge; incorrect decisions may lead to losses on both sides
- Prolonged locked positions accumulate swap costs on both sides, continuously draining account balance
Possible improvements
- Add automatic unlock logic based on technical indicators to reduce risk from subjective judgment
- Incorporate money management and margin monitoring modules to prevent insufficient margin from locking
Risk assessment
Overall risk: Medium
- Double margin consumption from locked positions may trigger margin calls during high volatility
- Improper unlock timing may result in losses on both sides rather than protection
Evaluation scores
Parameters
| Parameter | Default | Description |
|---|---|---|
LockProfit | 0 | Profit lock threshold |
LockLoss | 0 | Loss lock threshold |
UnlockProfit | 0 | Profit unlock threshold |
LotSize | 0.01 | Initial lot size, martingale base quantity |
MagicNumber | 0 | EA magic number to distinguish trade instances |
Slippage | 3 | Allowed slippage |
Similar Hedging EAs
Backtests are historical simulations and do not guarantee future results. Not financial advice.