Pending Grid Builder
Placing ten pendings by hand means ten chances to fat-finger a price, and the terminal's order window will happily let you. This script builds the whole ladder in one pass: choose the flavour (buy limits below the market, sell limits above, buy stops above, sell stops below), a start price, a spacing, a rung count and a volume, and every rung is computed, validated and placed with an optional stop loss and take profit hung off its own entry price. The risk warning comes before the feature list, because a grid deserves one: a ladder of pendings is AGGREGATE exposure. Every rung that fills adds to the position, and a fully filled grid without stops has open-ended downside. The confirmation dialog does that arithmetic for you - total lots, the approximate margin to carry a full fill, and the combined loss if every rung fills and every stop is hit, in account currency, computed from tick value and tick size so it is correct on JPY crosses, gold and index CFDs, not just on EURUSD. If you run it without a stop loss, the dialog says in plain words that the downside is open-ended. Prices are snapped to the tick-size grid - not merely rounded to digits, which index CFDs with a 0.25 tick reject - and always on the side that keeps the rung outside the broker's stop and freeze levels. An explicit start price on the wrong side of the market, or inside the minimum distance, is refused with the nearest legal price printed rather than silently moved: a level you chose should never be quietly re-chosen for you. In auto mode (start price 0) the first rung goes one spacing from the market, pushed out to the legal minimum if the spacing is tighter. A rung that fails permanently does not abort the run - a grid missing one rung is still a grid - but the journal names every uncovered level and the summary counts them, so nothing fails in silence. Notes and limitations - This script places orders once and exits. It does not replace filled rungs, trail anything, or close the basket - it is a builder, not a grid robot. - Pending orders reserve no margin. A grid that fits today can be rejected rung by rung at trigger time if the account cannot carry the fills. - The worst-case loss figure assumes every rung fills and every stop is hit with no slippage; a gap through the ladder can exceed it. - On a netting MT5 account the per-rung stops overwrite each other as rungs fill; manage the merged position's stop yourself. - Tick value is read from the broker; on an unsynchronised symbol it can be zero, in which case the money figure is omitted rather than invented. - Use Delete All Pending Orders (or your platform's order window) to remove a half-built or stale ladder; this script only builds.
Script · MT5 · v1.0 · Free
About Pending Grid Builder
Pending Grid Builder is an expert advisor (trading robot) for MetaTrader 5. It opens a grid of orders at fixed price steps and places pending buy/sell stop or limit orders. It has 12 settings, such as Grid kind, Order count and Lots per order. MQL source code included.
Files in the download: PendingGridBuilder.ex5, PendingGridBuilder.mq5, PendingGridBuilder.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 |
|---|---|---|
| Grid kind | GRID_BUY_LIMIT | Ladder type |
| Order count | 5 | Number of rungs |
| Lots per order | 0.01 | Lots per rung |
| Start price | 0.0 | First rung price (0 = auto) |
| Spacing pips | 15.0 | Spacing between rungs, pips |
| Stop loss pips | 0.0 | Stop loss per rung, pips (0 = none) |
| Take profit pips | 0.0 | Take profit per rung, pips (0 = none) |
| Expiry | D'1970.01.01' | Expiry (leave 1970 = no expiry) |
| Magic | 0 | Magic number |
| Max retries | 5 | Attempts per rung before giving up |
| Retry wait ms | 500 | Pause between attempts, ms |
| Confirm first | true | Ask for confirmation first |
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 · Volume · Pending Orders · MT5 Script · MQL5 Source Code