Loading…

Staged Order Queue

Most traders plan entries away from the screen - a level to buy if price reaches it, a breakout to sell if it happens overnight - and then either sit watching for it or miss it entirely. A single pending order covers one simple case, but a real watch list of staged plans across several symbols, each with its own condition, quickly outgrows what the platform's own pending order dialog can hold cleanly, especially when some triggers are price based and others are time based. This EA reads its plans from a CSV file instead: one row per staged trade, each with a symbol, direction, trigger type (price at or above a level, price at or below a level, or a specific date and time), lot size, stop and target in pips, and an Armed flag. Every poll it re-reads the file from disk, checks every armed and not-yet-fired row against the current market, and sends the order the instant a condition is satisfied. Because the file is re-read each time, plans can be added or edited while the EA keeps running - no restart needed to stage one more idea. The "Fired" column is the part that matters under real conditions: the instant a plan executes, that row is written back to the same file with Fired set, so a terminal restart, a crash, or simply re-attaching the EA never re-sends a plan that already went out. Notes and limitations - Columns, in order: Symbol, Direction (BUY/SELL), TriggerType (PRICE_ABOVE/PRICE_BELOW/TIME), TriggerValue (a price, or a yyyy.mm.dd hh:mi timestamp for TIME), Lots, StopLossPips, TakeProfitPips, Comment, Armed (1/0), Fired (1/0). - Price triggers compare against Bid for both directions, for a single consistent trigger price regardless of which side of the market the plan trades. The actual order is still sent at Ask for a BUY and Bid for a SELL, as normal. - A plan whose stop or target sits inside the broker's minimum stop distance is skipped and retried on the next poll rather than sent broken - fix the pips in the file and it will fire on the next check. - If a plan's OrderSend fails after every retry, Fired stays false and it is retried again on the next poll. A plan that keeps failing has a genuine problem (bad stop distance, symbol not tradable) and should be disarmed (Armed=0) until fixed. - Lot size is normalised to the traded symbol's own step, minimum and maximum before sending, never assumed. - This tool only ever sends the market order defined in the row; it does not manage the trade afterwards.

Expert advisor · MT4 · v1.0 · Free

About Staged Order Queue

Staged Order Queue is an expert advisor (trading robot) for MetaTrader 4. It has 6 settings, such as Queue file name, Poll seconds and Magic. MQL source code included.

Files in the download: StagedOrderQueue.ex4, StagedOrderQueue.mq4, StagedOrderQueue.txt.

Trading robots can lose money. Check every setting and test on a demo account before using real funds.

Settings

SettingDefaultWhat it does
Queue file nameStagedOrderQueue.csvTrade plan file, MQL4\Files
Poll seconds5How often the queue file is re-read and checked
Magic20261212Magic number tagging every order this EA sends
Slippage pips3Slippage tolerance, in pips
Max retries5Attempts per order before giving up for this poll
Retry wait ms500Pause between attempts, milliseconds

How to install

  1. Download the ZIP from your PolyMaria library and unzip it.
  2. In MetaTrader 4 open File → Open Data Folder, then go to MQL4 → Experts.
  3. Copy the .mq4 file(s) there. Put any .mqh files in MQL4 → Include.
  4. Open the .mq4 file in MetaEditor and press Compile (F7) if MetaTrader does not show it.
  5. Drag the expert advisor from the Navigator onto a chart, check the settings, allow Algo/Auto Trading and press OK.
  6. Test it first on a demo account or in the Strategy Tester.

Download the PDF guide

Tags: Breakout · Pending Orders · MT4 Expert Advisor · MQL4 Source Code

Expert advisors (EA) for MT4 & MT5 · PolyMaria