Pending Order Rearm and OCO Manager
- 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.2
- Activations: 5
Pending Order Rearm and OCO Manager watches the pending orders that you place yourself in MetaTrader 5. When a watched order is filled and the position is then closed by its stop-loss, the tool places the same pending order again: same type, price, stop-loss, take-profit, lot and expiry. It can also link two pending orders as an OCO pair (one cancels the other): when one of them is filled, the other is deleted.
This is a tool that repeats orders you have decided on. It makes no trade decisions, gives no signals and is not a trading strategy. A re-arm means entering again after a stop-loss, so losses can add up: if the price keeps reaching your stop-loss, each re-arm can end in another loss. No profit is promised. For this reason a limit per order, a limit per day and a daily loss limit are switched on by default.
Who it is for: traders who place pending orders by hand at price levels they have chosen and want the same order back after a stop-out, within limits they set, without placing it again by hand each time.
Features
- Re-arm after a stop-loss: the new order has the same type, price, SL, TP, lot and expiry as the original. It is a new order with a new ticket number. The lot is never increased (no martingale, no averaging down).
- Re-arm after a take-profit as well: optional, off by default.
- Limits, all on by default: re-arms per order (3), re-arms per day for all orders together (10), daily loss limit of the watched trades (2% of the balance at the start of the day, or an amount in the account currency) and a waiting time after the stop-loss (5 minutes).
- If the price is already past the order price: wait until it comes back (default) or give up.
- OCO: two pending orders of the same symbol with the same tag in the comment (for example OCO1), or paired on the panel with the O buttons. When one is filled, even partly, the other is deleted. When both orders are set to re-arm, the deleted order is placed again right after the other one is re-armed, but only if its price can still be placed and the limits allow; otherwise it waits for the price to come back, so for a while only one order of the pair may be in the market.
- Which orders: a word in the order comment (default "RA"), a magic number, or only the orders you add on the panel with +. By default only manual orders (magic 0).
- Panel: watched orders, re-arm count, status with the reason while waiting or after stopping, today's re-arms and the result of the watched trades, Pause / Resume button. 11 languages.
- No double orders after a restart: the state is saved in a file and in global variables, and before placing an order the tool checks whether the same order already exists and takes it over.
- CSV log of every action. Pop-up, sound, push and e-mail alerts.
- No DLL, no WebRequest, no outside server.
Main Inputs
- Which pending orders to watch: watch orders by (default: comment marker), comment marker (default RA), marker / panel: manual orders only, magic 0 (default on), magic number (used when watching by magic number), symbols (all symbols or this chart's symbol only; default all).
- Re-arm after a stop-loss: also re-arm after a take-profit (default off), max re-arms per order (default 3, 1-1000), max re-arms per day, all orders (default 10, 1-10000), daily loss limit of watched trades (default 2.0, 0 = off), unit (default % of the balance at the start of the day, or account currency), wait after the stop-loss (default 5 minutes, 0-1440), if the price is already past the order price (default: wait until it comes back, or give up).
- OCO: on (default on), OCO tag in the comment (default OCO).
- Alerts (re-armed / stopped): pop-up (default on), sound, sound file, push, e-mail.
- Panel: show, language (default: terminal language), corner, X / Y offset, font size, rows of watched orders.
- Other: CSV log (default on), Strategy Tester demo orders (default on, works only in the tester).
How It Works
- A pending order is watched when its comment contains the marker as a separate word (not case sensitive, for example "RA" or "RA breakout"), when it has the magic number you chose, or when you press + next to it on the panel. With "manual orders only" (default) orders of other EAs are ignored. Market orders are never watched. Orders that do not match are never touched.
- After a fill the tool follows the position. When the position is closed by its stop-loss, the order is placed again after the waiting time. This also applies when you moved the stop-loss to break-even or into profit (trailing) and it was then hit. A position closed by hand, by another EA or by its take-profit (unless that option is on) ends the watch for that order. If you close part of the position by hand and the rest is closed by the stop-loss, the order is re-armed with the original lot.
- If you change a watched pending order (price, SL, TP, expiry) while it waits, the changed order becomes the new original for later re-arms.
- If you place the same order yourself after a stop-loss (same symbol, type, price, lot, SL, TP, magic and comment), the tool takes it over instead of placing a second one. This counts as one re-arm.
- Orders with an expiry are re-armed with the same expiry date and time. When the expiry has passed (or is less than one minute away), the watch for that order ends.
- If the price is already past the order price, or closer to it than the broker's stop level allows, the tool by default waits until the order can be placed. There is no time limit on this wait. With "give up" the watch for that order ends.
- The limits count per order and per day. The day starts at 00:00 server time. An order stopped by a limit is not resumed automatically on the next day; place a new order if you want to continue.
- Daily loss limit: it counts the result of the watched trades closed today (profit and loss together, including swap and commission), not the whole account. In %, it uses the balance at 00:00 server time, or the balance when the tool was attached later that day; this base stays the same after a restart. When the limit is reached, only re-arming stops: open positions and pending orders are not closed or deleted, so the real loss can go beyond the limit. Re-arming an OCO pair counts as two re-arms.
- OCO: when one order of a pair is filled, the other is deleted. If the other order is filled before it can be deleted, the panel and the log say so. While the tool is paused, OCO is paused too, so both orders can be filled.
- Orders that cannot be placed (invalid price, not enough margin, market closed, trading not allowed): nothing is placed, the panel shows the reason, and the tool waits or gives up as set. If the server rejects the order three times, the watch for that order ends.
- Panel buttons: x stops watching an order (or removes a finished row), O selects an order for an OCO pair (press O on two orders of the same symbol), + watches an order from the list of other pending orders, Pause / Resume stops and restarts re-arming and OCO for all orders.
- CSV log: MQL5\Files\PendingReArm\log_<account>_<server>.csv with 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 others), ticket, new ticket, symbol, type, price, SL, TP, volume, expiry, magic, count, reason and detail.
Notes and Limits
- Re-arming does not improve results. It repeats your order and its risk. Several stop-losses in a row mean several losses in a row, up to the limits you set.
- It works only while MetaTrader 5 is running and connected. A VPS is recommended. A stop-loss hit while the terminal was off is handled at the next start (the order is re-armed then, within the limits).
- Algo Trading must be ON (toolbar button) and allowed in the EA settings.
- Hedging accounts are recommended. On a netting account the position from a filled order merges with other positions on the same symbol and cannot be told apart; the panel shows a warning.
- Only one chart per account acts. If the tool is attached to several charts, the others show the panel only and their buttons do nothing. For about 1-2 seconds after the start the panel is display only. If the acting chart is removed, another copy takes over within about 15 seconds.
- Use one terminal per account. Two terminals logged in to the same account cannot detect each other, and both would act.
- There is no function to place or delete orders at set times. The waiting time in minutes is only a gap after a stop-loss, so that the order is not filled again at once.
- Push and e-mail alerts need the notification settings of the terminal.
- Strategy Tester: there are no manual orders in the tester, so the tool places its own small demo orders there to show re-arming and OCO (input "Strategy Tester demo orders"). Tester results are not a measure of this product.
- Display: the panel can overlap the One Click Trading panel or the trade arrows; move it with the corner and X / Y inputs. Its width depends on the language (up to about 730 px).
Compatibility and Support
- MetaTrader 5, hedging accounts recommended. Order types: Buy / Sell Limit, Buy / Sell Stop, Buy / Sell Stop Limit. Attach it to one chart of any symbol; it watches all symbols unless you choose this chart's symbol only.
- No DLL and no outside server. Files are written only in MQL5\Files\PendingReArm\.
- Panel in 11 languages (English, Japanese, Russian, German, French, Chinese, Korean, Turkish, Spanish, Portuguese, Italian), automatic from the terminal language.
- Support through MQL5 messages, reply within 3 business days: installation, settings and bug reports. We cannot tell you where to place orders, which limits to use or whether to trade, and we do not give market views.
Disclaimer
- This product is a software tool, not investment advice. It does not recommend any symbol, price level or setting. Trading leveraged products carries a high risk of loss, and re-arming after a stop-loss can add further losses. No profit is promised or implied, and it is not guaranteed that losses stay within your limits. Test on a demo account first. Your orders, settings and trading are your own responsibility.
