Pending Order Grid Manager
RISK WARNING: a pending-order grid can accumulate real exposure across several filled levels in a strongly trending market, and every level here carries its own stop-loss and take-profit but the grid as a whole can still lose money faster than a single position would. Test on a demo account first, understand every input before going live, and never raise InpLotMultiplier above 1.0 without fully understanding that this turns a flat grid into a compounding one. Most published grid EAs place every level and stop there - nothing caps how many levels can fill, and nothing watches the combined floating loss across the whole grid. This one is built the other way round: deployment itself refuses to place a level that would push the running total over InpMaxTotalLots, and a separate basket stop-loss, checked independently on every scan, flattens every position and cancels every remaining pending order the instant floating loss reaches InpBasketStopLossPercent of account balance. Both are on by default. InpLotMultiplier defaults to 1.0 - every level uses the same base lot size, so filling more levels adds exposure linearly, not exponentially. Raising it compounds lot size outward from the centre, which is a deliberate, martingale-adjacent choice the trader has to opt into; it is never the starting point. The grid is symmetric by construction: buy stops are placed above price and sell stops below it, so a level only fills on a genuine breakout past that level in either direction, not as an averaging-down ladder in a single direction. Every level's own stop-loss and take-profit is attached at send time - the basket stop-loss is a second line of defence, checked on a timer, not the only protection a fast move between checks would otherwise leave a filled level without. Notes and limitations - The lot cap and basket stop-loss are the only protection against a strongly trending market filling every level on one side. There is no guarantee the basket stop-loss closes at the loss percentage configured - slippage and gaps mean the actual loss can exceed it, particularly around news. - A level whose entry price would fall inside the broker's minimum stop distance from current price is skipped rather than sent and rejected - this typically only affects level 1 with a very tight InpGridStepPips. - Running more than one instance on the same symbol with the same InpMagicNumber will double-count that grid's own lots and P/L against the cap - use a different magic number per instance. - MQL5 version only: requires a hedging account. It will not deploy at all on a netting account - see "MQL4 VERSUS MQL5 DIFFERENCES" above.
Expert advisor · MT5 · v1.0 · Free
About Pending Order Grid Manager
Pending Order Grid Manager is an expert advisor (trading robot) for MetaTrader 5. It increases the lot size after a losing trade (martingale), opens a grid of orders at fixed price steps and places pending buy/sell stop or limit orders. It has 16 settings, such as Lots, Lot multiplier and Grid levels. MQL source code included.
It also can size trades from your balance and risk percent.
Files in the download: GridManager.ex5, GridManager.mq5, GridManager.txt.
Trading robots can lose money. Check every setting and test on a demo account before using real funds.
Settings
| Setting | Default | What it does |
|---|---|---|
| Lots | 0.01 | Base lot size for the first grid level |
| Lot multiplier | 1.0 | Lot multiplier per level outward (1.0 = flat, no compounding) |
| Grid levels | 5 | Number of levels on EACH side (buy stops above, sell stops below) |
| Grid step pips | 20 | Spacing between levels, in pips |
| Stop loss pips | 50 | Stop-loss per level, in pips from that level's entry (0 = not allowed, see notes) |
| Take profit pips | 30 | Take-profit per level, in pips from that level's entry (0 = none) |
| Max total lots | 0.50 | Hard cap on combined lots across every level - deployment stops here |
| Use basket stop loss | true | Flatten the whole grid if floating loss breaches the cap below |
| Basket stop loss percent | 10.0 | Emergency close-all trigger, % of account balance in floating loss |
| Auto refill | false | Redeploy a level that fills or is removed, up to InpGridLevels and the lot cap |
| Expiry hours | 0 | Pending order expiry, hours (0 = good till cancelled) |
| Magic number | 20260701 | Magic number - scopes every calculation and action to this grid only |
| Slippage pips | 5 | Slippage tolerance on any market action (basket stop-loss close) |
| Max retries | 5 | Attempts per order action before giving up |
| Retry wait ms | 500 | Pause between attempts, milliseconds |
| Scan interval sec | 20 | Seconds between maintenance scans |
How to install
- Download the ZIP from your PolyMaria library and unzip it.
- In MetaTrader 5 open File → Open Data Folder, then go to MQL5 → Experts.
- Copy the .mq5 file(s) there. Put any .mqh files in MQL5 → Include.
- Open the .mq5 file in MetaEditor and press Compile (F7) if MetaTrader does not show it.
- Drag the expert advisor from the Navigator onto a chart, check the settings, allow Algo/Auto Trading and press OK.
- Test it first on a demo account or in the Strategy Tester.
Tags: Grid · Trend · Pending Orders · Martingale · Risk & Lot Size · MT5 Expert Advisor · MQL5 Source Code