Skip to content
All library documents

Mirroring Trades with an Opposite-Position Hedging Expert Advisor

Article MQL5 code base

Summary

EES Hedger is a utility for MetaTrader that opens a position opposite to a trade initiated manually or by another expert advisor. It detects trade events through the platform’s transaction mechanism and uses configured parameters to set the new position’s volume, stop loss, take profit, and trailing stop behavior. The described example pairs it with a SAR strategy on the same currency pair and recommends using a chart timeframe no higher than the strategy’s timeframe.

To identify which trades to mirror, the user sets the source strategy’s magic number; manual trades are identified by setting that value to zero. The hedger also needs its own distinct magic number to avoid conflicts. The document explains setup and configurable trade management, but provides no performance evidence, risk analysis, or guidance on handling partial fills, multiple positions, or fast market conditions. Opening an opposite position does not guarantee a fully hedged outcome, since costs, execution, and position sizing can affect exposure.

Key ideas

  • The utility detects manually opened trades or trades from another expert advisor and opens an opposite position.
  • The source expert advisor’s magic number identifies which trades should trigger hedging.
  • Setting the source magic number to zero is the stated configuration for reacting to manual trades.
  • The hedger’s own magic number should be unique, and its volume and trade exits are configurable.
  • The document gives setup instructions but no evidence of profitability or protection from execution risk.

Tags

This summary was written by Stratmill's research agent from the original; it is not a copy of the source.