Trading robot · MT5

XAU Hedge Strategy

by mraicodedev

This MetaTrader 5 expert advisor executes a coordinated hedging strategy across two separate accounts for XAUUSD.

GitHub stars1
Forks1
Last update7 months ago9 Feb 2026
LicenceCustom licence

Overview

By running one instance as a buyer and another as a seller, the system coordinates simultaneous opposing entries. The two instances communicate status and synchronization via shared local files. It manages risk through fixed lot sizing and take profit targets calculated from a specific dollar amount. The system only initiates trades when account balances are within a defined range. Notably, the strategy does not include a standard stop loss.

Details

Author

mraicodedev on GitHub

Type

Trading robot

Platform

MetaTrader 5 (MQL5)

Strategy

Hedging

Markets

Gold

Timeframes

Any timeframe

Risk profile

  • Holds opposite positions at once
  • Trades without a fixed stop loss

Input parameters

Read from XAU_Hedge_Strategy.mq5. Defaults are the author's; change them in the EA's Inputs tab.

NameTypeDefaultDescription
InitialBalancedouble50.0Số dư tối thiểu ($)
MaxBalancedouble55.0Số dư tối đa ($)
LotSizedouble0.15Khối lượng giao dịch
TakeProfitAmountdouble60.0TP khi lợi nhuận đạt ($)
Symbol_TradestringXAUUSDCặp tiền giao dịch
MagicNumber_Bint100001Magic number cho tài khoản B (BUY)
MagicNumber_Sint100002Magic number cho tài khoản S (SELL)
IsAccountBbooltruetrue = Tài khoản B (BUY), false = Tài khoản S (SELL)
SharedFolderstringXAU_HedgeThư mục chia sẻ trong MQL5\Files
IAgreeToRiskDisclaimerboolfalse⚠️ TÔI ĐÃ ĐỌC VÀ CHẤP NHẬN RỦI RO (Đặt = true để sử dụng)

How to install it

  1. 1Download the sourceUse "Download source (.zip)" above, or clone mraicodedev/xau-hedge-strategy from GitHub, and unzip it.
  2. 2Open the data folderIn MetaTrader choose File, then Open Data Folder, and go to MQL5/Experts.
  3. 3Copy the filesCopy the .mq5 file into Experts.
  4. 4Compile in MetaEditorOpen the file in MetaEditor and press Compile. Fix any missing includes the compiler reports.
  5. 5Test before you tradeRun it in the Strategy Tester, then attach it to a demo chart and allow algorithmic trading.
Third-party code. ForexR did not write, test or endorse this EA, and the summary above was generated automatically from its README and code. ForexR lists only repositories with readable source code and never hosts files. Read the code, backtest it and use a demo account first; automated trading can lose money quickly.

Similar expert advisors

Nyao Scalper

by elrizwiraswara
173 stars

Nyao Scalper is an automated scalping robot for MetaTrader 5 that utilizes a multi-factor weighted scoring system to identify trade opportunities. It evaluates trend alignment through EMA crossovers, momentum via RSI, and price action through wick rejection and candle body analysis. The EA manages risk with adaptive AT

MT5 Trading robot ScalpingTrend followingMartingale High risk
Updated 3 months ago BSD-3-Clause GitHub repository of Nyao Scalper
18 stars

This expert advisor for MetaTrader 5 utilizes a genetic algorithm and neural network to make autonomous trading decisions without relying on traditional technical indicators. It implements a self-learning mechanism that evaluates a population of species to determine entry, exit, and lot sizing across multiple currency

MT5 Trading robot AI / machine learningHedging
8 stars

High Frequency Grid EA is an automated trading robot for MetaTrader 5 that implements a mean-reversion strategy through a grid of pending orders. It places buy and sell stop orders at calculated distances, using dynamic spread monitoring to ensure execution only during favorable conditions. The EA includes a trailing s

MT5 Trading robot GridMean reversionScalping High risk

Grid Trading MT5

by algocode2022
6 stars

This grid trading robot for MetaTrader 5 automates the placement of multiple limit orders within a user-defined price range. It populates the market with a configurable number of buy and sell limit orders between specified high and low boundaries. The expert advisor includes risk management features such as individual

MT5 Trading robot GridHedging High risk
Updated 2 years ago GPL-3.0 GitHub repository of Grid Trading MT5

DBasket EA

by dinethlive
5 stars

DBasket EA is a statistical arbitrage expert advisor for MetaTrader 5 that trades three-pair correlation baskets. It identifies price divergences between related currency pairs using Z-score analysis and enters hedged three-leg positions expecting mean reversion. The system incorporates advanced statistical modules inc

MT5 Trading robot Mean reversionHedging
Updated 8 months ago None stated GitHub repository of DBasket EA

EA XAUUSD Premium

by diditgravatar
4 stars

This MetaTrader 5 expert advisor is designed for gold trading, utilizing a multi-timeframe strategy across the M15, H1, and H4 charts. It integrates technical indicators including ADX, RSI, and Moving Averages to identify trend-following and breakout opportunities. Risk controls include dynamic lot sizing based on acco

MT5 Trading robot Trend followingBreakoutGrid High risk
Updated 1 year ago None stated GitHub repository of EA XAUUSD Premium

More trading robots

Need a broker for MT5?

Compare regulated brokers that support MetaTrader, with spreads, minimum deposits and leverage side by side.

Compare brokers