Pending Order Rearm and OCO Manager MT4
- Utilities
-
Kazuma Uezono
MQL5 / MQL4 / Pine Script v6 developer and active trader.
Seller on the MQL5 Market (indicators for MT4/MT5).
Services:
- TradingView Pine Script to MT5/MT4 conversion (bar-by-bar matching, with tester report)
- MT4 to MT5 migration - Version: 1.3
- Updated: 17 November 2026
- Activations: 5
Pending Order Rearm and OCO Manager MT4 is a utility EA for MetaTrader 4 that looks after the pending orders you enter by hand. You set a Buy Limit, Sell Limit, Buy Stop or Sell Stop as usual; if that order fills and the trade is then stopped out, the EA enters the same pending order again with the same price, stop-loss, take-profit, lot and expiry. A second job is OCO (one cancels the other): link two pending orders, and when one fills the EA deletes the other.
What it does not do: it does not decide when or where to trade, it shows no signals and it is not a strategy. Entering again after a stop-out can lead to one loss after another, because each new order can be stopped out too. No profit is promised. That is why the per-order limit, the per-day limit and the daily loss limit are already active in the default settings.
Who it is for: MT4 traders who work with pending orders at their own price levels and would like a stopped-out order to come back automatically, as many times as they allow and no more.
Features
- Rearm after a stop-out: same order type, price, SL, TP, lot and expiry as the order you placed. MT4 gives it a new ticket number. The lot never grows (no martingale, no averaging down).
- Rearm after a take-profit: optional, off by default.
- Limits active by default: 3 rearms per order, 10 rearms per day across all orders, a daily loss limit for the watched trades (2% of the day's opening balance, or a fixed amount in the account currency) and a 5-minute pause after each stop-out.
- When the market has already moved past the order price: keep waiting until it returns (default) or give up.
- OCO: two pending orders on the same symbol that share a tag in the comment (for example OCO1), or two orders linked with the O buttons on the panel. The fill of one deletes the other. If both orders are set to rearm, the deleted one is sent again right after its partner is rearmed, provided its price is still valid and the limits allow; if not, it waits for the market to come back, so only one order of the pair may be live for a while.
- Selection: a word in the order comment (default "RA"), a magic number, or only orders you add with the + button. Out of the box only manual orders (magic 0) are picked up.
- Panel: list of watched orders with rearm count and status (why it waits or why it stopped), today's rearm count and result of the watched trades, Pause / Resume. 11 panel languages.
- After a restart: state kept in a file and in global variables; before sending an order the EA looks for an identical one and adopts it instead of sending a duplicate.
- CSV record of every action. Alerts by pop-up, sound, push or e-mail.
- No DLL, no WebRequest, no outside server.
Main Inputs
- Which pending orders to watch: watch orders by (comment marker by default), comment marker (RA), marker / panel: manual orders only, magic 0 (on), magic number (for the magic number mode), symbols (all symbols by default, or only the chart's symbol).
- Re-arm after a stop-loss: also re-arm after a take-profit (off), max re-arms per order (3, range 1-1000), max re-arms per day, all orders (10, range 1-10000), daily loss limit of watched trades (2.0; 0 switches it off), daily loss limit unit (% of the day's opening balance by default, or account currency), wait after the stop-loss (5 minutes, range 0-1440), if the price is already past the order price (wait by default, or give up).
- OCO: OCO on (on), OCO tag in the comment (OCO).
- Alerts (re-armed / stopped): pop-up (on), sound, sound file, push notification, e-mail.
- Panel: show panel, language (terminal language by default), panel corner, horizontal / vertical offset, font size, rows of watched orders.
- Other: CSV log (on), Strategy Tester demo orders (on; used only inside the tester).
How It Works
- An order is picked up if its comment has the marker as a word of its own (upper or lower case, for example "RA" or "RA breakout"), if it carries the chosen magic number, or if you click + beside it on the panel. In the default "manual orders only" mode, orders from other EAs are skipped. Market orders are never picked up, and orders that do not match are left alone.
- Once the order fills, the EA follows the trade. If the trade is closed at its stop-loss, the order goes back in after the pause. This is also true when the stop-loss had been moved to break-even or into profit (trailing stop). A trade closed by you, by another EA, or at take-profit (with that option off) ends the watch on that order. If you close part of the trade by hand and the remainder is stopped out, the order goes back in with the original lot.
- Editing a watched pending order while it waits (price, SL, TP, expiry) makes the edited order the new model for later rearms.
- If you enter the same order yourself after a stop-out (same symbol, type, price, lot, SL, TP, magic number and comment), the EA adopts it and does not send a second one. That counts as one rearm.
- An order with an expiry goes back in with the same expiry date and time. Once that time has passed (or is less than a minute away), the order is no longer watched.
- When the market is beyond the order price, or nearer to it than the broker's stop level, the default is to wait until the order can be sent, with no time limit. With "give up" selected, the watch on that order ends.
- Limits are counted per order and per day; a new day begins at 00:00 server time. An order that hit a limit stays stopped on the following days too; enter a new order to start again.
- Daily loss limit: the sum of profits and losses (with swap and commission) of watched trades closed today. Trades that are not watched are not counted. In % mode the base is the balance at 00:00 server time, or at the moment you attached the EA if that was later in the day, and a restart does not change it. Reaching the limit only stops rearming; no trade is closed and no order is deleted, so the actual loss can end up larger than the limit. Rearming an OCO pair adds two to the count.
- OCO: the fill of one order deletes its partner. If the partner fills before it can be deleted, the panel and the log report it. Pausing the EA also pauses OCO, so both orders can fill during a pause.
- When an order cannot be sent (invalid price, not enough margin, market closed, trading disabled), nothing is sent: the panel shows why, and the EA waits or gives up as set. After three rejections by the server, the order is no longer watched.
- Panel buttons: x ends the watch on an order (or clears a finished row), O marks an order for an OCO pair (press O on two orders of one symbol), + adds an order from the list of other pending orders, Pause / Resume halts or restarts rearming and OCO for everything.
- CSV file: MQL4\Files\PendingReArm\log_<account>_<server>.csv. Columns: server time, event (WATCH, FILLED, CLOSED, REARM, REARMED, PLACED, ADOPT, MODIFIED, WAIT, FAIL, STOP, OCO_PAIR, OCO_DELETE, OCO_BOTH_FILLED, PAUSE, RESUME, DAY_START and more), ticket, new ticket, symbol, type, price, SL, TP, volume, expiry, magic, count, reason, detail.
Notes and Limits
- Rearming is not a way to trade better. It repeats your own order and its risk; a series of stop-outs is a series of losses, up to the limits you chose.
- How MT4 tells a stop-out: the EA reads "[sl]" in the closed trade's comment; if that is missing, it compares the close price with the stop-loss (within 2 points). A trade you close by hand very near its stop-loss can therefore be treated as a stop-out and rearmed.
- It runs only while MetaTrader 4 is open and connected; a VPS is recommended. If the terminal was off when a stop-loss was hit, the EA deals with it at the next start (rearming then, within the limits).
- The AutoTrading button must be on and live trading must be allowed in the EA properties.
- Only one chart per account does the work. Copies on other charts just show the panel, and their buttons have no effect. During roughly the first 1-2 seconds after start the panel is display only. If the working copy is removed, another copy takes over after up to about 15 seconds.
- Keep to one terminal per account: two MT4 terminals logged in to the same account cannot see each other and would both act.
- Nothing is timed: the EA has no feature to send or delete orders at a clock time. The pause in minutes only keeps a stopped-out order from filling again straight away.
- Push and e-mail alerts work only after you set them up in the terminal options.
- Strategy Tester: since there are no manual orders in the tester, the EA enters a few small demo orders of its own there to show rearming and OCO (input "Strategy Tester demo orders"). What the tester shows is not a performance figure for this product.
- Panel display on MT4: switch off "Chart on foreground" in the chart properties, otherwise the panel is hard to see. It can sit on top of the One Click Trading panel or trade arrows; move it with the corner and offset inputs. Width changes with the language (up to about 730 px). In Russian, the space after "·" can look squeezed on MT4; this is only how it looks.
- MT4 handles the text of the panel, alerts and the Experts log with the Windows language setting (ANSI code page). If the selected language uses characters that this Windows setting does not support (for example Korean on Japanese or English Windows), the EA uses English automatically.
Compatibility and Support
- MetaTrader 4. Order types: Buy Limit, Sell Limit, Buy Stop, Sell Stop. Put it on one chart of any symbol; it covers all symbols unless you limit it to the chart's symbol.
- No DLL, no outside server. It writes files only in MQL4\Files\PendingReArm\.
- 11 panel languages (English, Japanese, Russian, German, French, Chinese, Korean, Turkish, Spanish, Portuguese, Italian), chosen from the terminal language.
- Support by MQL5 message, answered within 3 business days, for installation, settings and bug reports. I cannot say where to place orders, which limits to choose or whether to trade, and I do not share market opinions.
Disclaimer
- This EA is a software utility and not investment advice; it does not recommend any symbol, price or setting. Leveraged trading carries a high risk of loss, and entering again after a stop-out can add to it. No profit is promised or implied, and there is no guarantee that losses stay inside your limits. Please try it on a demo account first. All orders, settings and trades are your own responsibility.
