Trading robot · MT5

Grid Trader MT5

by zhangwenwei

This expert advisor for MetaTrader 5 implements a bidirectional range grid strategy based on user-defined price boundaries.

High risk

GitHub stars1
Forks1
Last update2 months ago27 Jun 2026
LicenceNone stated

Overview

Grid Trader MT5 automatically divides the range into two halves, executing sell orders in the upper section and buy orders in the lower section. The system includes a safety mechanism that closes all positions if the price breaks out of the specified range. Risk is managed through a total pip-based take profit or a trailing drawdown exit. Lot sizes can be configured to decrease as positions move toward the center line.

Details

Author

zhangwenwei on GitHub

Type

Trading robot

Platform

MetaTrader 5 (MQL5)

Strategy

Grid, Mean reversion, Hedging

Markets

Any symbol

Timeframes

Any timeframe

Risk profile

  • Opens a grid of orders: exposure builds up in a trend
  • Holds opposite positions at once
  • Trades without a fixed stop loss

EA files

Input parameters

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

NameTypeDefaultDescription
TradeGrid_EnableBuybooltrueTradeGrid_EnableBuy | ?
TradeGrid_EnableSellbooltrueTradeGrid_EnableSell | ?
TradeGrid_UpperPricedouble0TradeGrid_UpperPrice | 网格上边界价 (?
TradeGrid_LowerPricedouble0TradeGrid_LowerPrice | 网格下边界价 (?
TradeGrid_GridCountint10TradeGrid_GridCount | 网格数量 (>=2; 把区间等分, 格距自动算)
TradeGrid_FirstAtEdgebooltrueTradeGrid_FirstAtEdge | 第一单须?
LotForLine_InitLotsdouble0.01LotForLine_InitLots | 边界处初始手数 (最靠边界, 最大)
LotForLine_ReducePerLinedouble0.0LotForLine_ReducePerLine | 每向中线拉开一格减少的手数 (0=固定手数)
LotForLine_MinLotsdouble0.01LotForLine_MinLots | 最小手数下限
TpThreshold_BasePipsint30TpThreshold_BasePips | 止盈阈值(总pips): 固定止盈触发值 / 移动止损1单时启动值
TrailTotal_EnableboolfalseTrailTotal_Enable | 开启移动止损 (ON 替代总体止盈)
TrailTotal_KeepPctint70TrailTotal_KeepPct | 回撤到峰值的百分之多少(%)就平; 越大越紧. 例80=跌到峰值80%即平
Show all 20 inputs
NameTypeDefaultDescription
TrailTotal_AddPerOrderint0TrailTotal_AddPerOrder | 每多持一单, 回撤触发百分比额外收紧的百分点 (0=不随单数变; 上限90%; 例基准70+每单5->1单70/2单75/3单80)
BreakoutDist_AtrMultdouble1.0BreakoutDist_AtrMult | 越界/恢复距离 = 此倍数 × ATR
BreakoutDist_AtrPeriodint14BreakoutDist_AtrPeriod | ATR 周期
LossCut_MinOrdersint0LossCut_MinOrders | ?
OnTick_MaxSpreadint0OnTick_MaxSpread | 最大点差(points), <=0 不限制
CTrade_Magiclong20240601CTrade_Magic | 魔术号
CTrade_Slippageulong30CTrade_Slippage | ?
DrawLines_ShowGraphicsbooltrueDrawLines_ShowGraphics | 画图总开?

How to install it

  1. 1Download the sourceUse "Download source (.zip)" above, or clone zhangwenwei/mt5-grid-trader 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

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
3 stars

This expert advisor facilitates arbitrage trading between futures and spot instruments, primarily targeting gold and stock indices. Available for MetaTrader 4 and 5, it monitors the price difference between two related symbols against a moving average to identify trade opportunities. The logic includes a noise-filterin

MT4MT5 Trading robot ArbitrageMean reversionGrid High risk
Updated 3 years ago None stated GitHub repository of Gold Futures Spot Arbitrage

AW Full Recovery EA

by wongthep
2 stars

This MetaTrader 5 expert advisor functions as a grid-based recovery system that can operate independently or manage trades from external EAs via magic number filtering. It initiates entries using Bollinger Bands and RSI indicators, then manages drawdown through a recovery grid matrix. The system employs dynamic ATR-bas

MT5 Trading robot GridMartingaleHedging High risk
Updated 3 months ago None stated GitHub repository of AW Full Recovery EA

Advanced Grid Trading

by jepli-1225
2 stars

Advanced Grid Trading is a MetaTrader 5 expert advisor that manages a complex grid strategy across four configurable layers. It places stop and limit orders at fixed intervals, employing either fixed or geometric lot scaling for increased grid depth. Trade management includes a shared profit pool used to close losing p

MT5 Trading robot GridMartingaleMean reversion High risk
Updated 6 months ago None stated GitHub repository of Advanced Grid Trading
2 stars

This MetaTrader 5 expert advisor implements a multi-layered grid strategy that manages up to three independent grids simultaneously on a single instrument. It uses the Relative Strength Index (RSI) across different timeframes to determine the initial trade direction for each grid. The EA employs martingale lot scaling,

MT5 Trading robot GridMartingaleMean reversion High risk
Updated 2 years ago None stated GitHub repository of Springfield 3 Grids

Adaptive Quant Grid

by x001tk-Igor
1 stars

Adaptive Quant Grid is an automated trading system for MetaTrader 5 that utilizes a dynamic grid strategy. It adjusts grid spacing based on market volatility using the Average True Range indicator and includes a regime filter powered by ADX and EMA to distinguish between trending and ranging markets. The EA supports sy

MT5 Trading robot GridMean reversionHedging High risk

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