Fill Pending Now At Market
There is no MQL4 call that converts a resting pending order into a market fill in place - a pending order and a market position are always two separate tickets. Getting into the market right now, using the levels already set on a pending order, otherwise means reading its lot size and stops by hand, sending a market order, then remembering to delete the original. This script does all three steps in the order that actually protects the trader: it sends the market order FIRST, confirms the new ticket genuinely exists, and only then deletes the original pending order - deleting first would risk losing the position altogether if the market send then failed. The stop loss and take profit carried over from the pending order are re-validated against the fresh market fill price, not the old pending price, before anything is sent. A stop that was a valid distance from the resting order's price can be too close to the live market price to be accepted - the script catches this and refuses to send rather than having the broker silently reject the stop and leave the new position unprotected. Notes and limitations - Works on one ticket per run, chosen explicitly by number - it will not guess which pending order the trader means. - If the stop loss or take profit carried over from the pending order would be too close to the fresh market fill price, the script refuses to send anything and says so, rather than sending an unprotected position. - If the market order is sent successfully but deleting the original pending order then fails, the script raises an Alert() and leaves the (now redundant) pending order in place rather than retrying silently forever - it must be removed by hand in that case. - Slippage is fixed for the single market send; there is no partial- fill handling since MQL4 market orders fill fully or not at all.
Script · MT5 · v1.0 · Free
About Fill Pending Now At Market
Fill Pending Now At Market is an expert advisor (trading robot) for MetaTrader 5. It places pending buy/sell stop or limit orders. It has 5 settings, such as Ticket, Slippage pips and Max retries. MQL source code included.
Files in the download: FillPendingNow.ex5, FillPendingNow.mq5, FillPendingNow.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 |
|---|---|---|
| Ticket | 0 | Ticket number of the pending order to fill now |
| Slippage pips | 3 | Slippage tolerance, pips |
| Max retries | 5 | Attempts before giving up |
| Retry wait ms | 500 | Pause between attempts, milliseconds |
| Confirm first | true | Ask for confirmation before sending |
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: Risk & Lot Size · Pending Orders · MT5 Script · MQL5 Source Code