Expert Advisors • Indicators • Scripts • Libraries

MQL.RobotFX.org is the biggest collection of MetaTrader expert advisors (MT5 & MT4), indicators, scripts and libraries that can be used to improve trading results, minimize risks or simply automate trading tasks

Metatrader 5 Expert Advisor | Xander Grid RSI Gold | Source Code Included

New free code from MQL5: indicators, EAs, and scripts for traders.

A grid expert advisor for Gold (XAUUSD) that starts each basket on an RSI signal: when RSI comes back above the oversold level it opens a buy, when it comes back below the overbought level it opens a sell, always on a closed candle. A Reverse switch flips both signals if you trade the other way.

While a basket is open and price moves against it, the EA adds a new level every set distance in points, with a lot multiplier and a maximum number of levels. The first lot can be fixed or sized from a percent of balance or equity. The whole basket closes together at a target in money or in points from the average price, with an optional basket stop loss and an optional trading hours filter.

Be clear about what this is: a grid with a lot multiplier and no stop loss on each position. Margin use grows with every level, and a long move against the basket can take a large part of the account when the basket stop is off. Run it in the Strategy Tester first and size the lot, the step and the number of levels to your own account. No result is promised.

Capture price channel breakouts with the Price Channel Expert Advisor. Precise entries and exits. Explore now.

Image for Xander Grid RSI Gold

Settings

Strategy

  • RSI period (14) and RSI applied price (Close).
  • Oversold level (30): a buy basket starts when RSI comes back above it.
  • Overbought level (70): a sell basket starts when RSI comes back below it.
  • Reverse signals (false): buy at overbought and sell at oversold instead.
  • Only one direction open at a time (true): no sell basket while a buy basket is running, and the other way around.

Lot settings

  • Lot mode (Fixed lot): or Percent of balance, or Percent of equity.
  • Fixed lot (0.01) and Percent used to size the first lot (0.5): in percent mode the first lot uses that share of balance or equity as margin.
  • Lot multiplier per grid level (1.5): 1.0 keeps the same lot on every level.
  • Maximum grid levels per direction (8).
  • Distance between levels (400 points).

Close / Exit

  • Basket take profit mode (Money): or Points from the average price.
  • Basket take profit (5.0): money in the account currency, or points.
  • Close the basket on the opposite signal (false).

Risk protection

  • Use a basket stop loss (false) and Basket stop loss (50, money): closes the whole basket when its loss reaches that amount.
  • Maximum positions of this EA at the same time (16).

Filters

  • Use the time filter (false), Start hour (8) and End hour (20), server time. The window can cross midnight. Outside it no basket starts and no level is added, while open baskets keep being managed.

Expert settings

  • Magic number (2610251), Order comment (XanderGridRSI), Max slippage (30 points), Show status on chart (true).

What it needs

  • MetaTrader 5 with Algo Trading enabled and a hedging account. On a netting account the levels merge into one position and the grid does not work as designed.
  • Distances are in points, so check the digits of your symbol. On a gold quote with 2 decimals 400 points are 4.00 in price, with 3 decimals they are 0.40.
  • It only manages positions with its own magic number on the chart symbol, so it can run next to other EAs and manual trades.

Make it yours

The whole entry lives in one function, XP_Signal(), which returns 1 for buy, -1 for sell and 0 for nothing. Replace it with any other indicator and you keep the same grid, lot sizing and basket exits with MACD, Bollinger Bands or Stochastic. Run your own backtest on XAUUSD, EURUSD, GBPUSD and BTCUSD, compare the steps and multipliers, and keep the basket stop on until you know how deep your settings can go. For partial exits on single trades, pair it with my Partial Close Multi TP Manager.

About this code

Open source. Use it as it is, adapt it, build your own version on top of it.

New versions and new tools are announced first on my MQL5 channel: https://www.mql5.com/en/channels/xander

Questions, suggestions and your own backtests are welcome in the Xander Lab group: https://www.mql5.com/en/messages/02eec85e4364dd01

More tools on my profile: https://www.mql5.com/en/users/09151993a

Provided as is, use at your own risk.

Related

  • Xander Grid XAUUSD
  • Partial Close Multi TP Manager
  • Basket Pair Closer

Changelog

  • v1.0 - 2026-10-25 - Initial release

Thanks for reading. Discover premium MetaTrader solutions at RobotFX.

79021

Best MetaTrader Indicators + Profitable Expert Advisors