Mirror Pendings To Opposite Side
A trader who does not know which way price will break often wants an order on both sides: a buy order to catch an upside break, a sell order at the mirrored distance to catch a downside one, with the loser cancelled once the winner fills. Building that pair by hand means reading off the original order's distance from the market and doing the arithmetic twice - once for the price, once for each stop level - for every pending that needs a partner. This script does that arithmetic for every matching pending order in one pass. The mirror axis is the midpoint between the current Bid and Ask, not either quote alone, so the mirrored distance matches the original distance rather than being a few points off by the width of the spread. Limit orders mirror to Limit orders, Stop orders mirror to Stop orders, and the buy/sell side flips - a Buy Stop above market becomes a Sell Stop below it, a Sell Limit above market becomes a Buy Limit below it - so the type of trigger is preserved, only the direction changes. Every mirrored order is tagged in its comment with the ticket it was built from. That tag does two things: it stops the script mirroring an order that is already a mirror of something else, which would otherwise double on every re-run, and it lets the script recognise that a given source ticket already has its mirror in place and skip creating a second one. Running the script repeatedly over a book that already has its mirrors built is a no-op, reported as such. Notes and limitations - The mirror axis is recalculated from the live Bid/Ask each time the script runs, not stored from when the source order was placed. If the market has moved a long way since the source was set, the mirror's distance from the CURRENT market matches the source's distance from the CURRENT market, not from wherever price was when the source was originally placed. - A mirrored stop or target that would land on the wrong side of the mirror's own entry, or inside the broker's minimum distance, is dropped from that mirror order and reported - the order itself is still created without it. - If the mirror price itself is not placeable against the current market, the whole mirror for that ticket is skipped, not sent with an adjusted price. - The comment tag used for duplicate detection takes up part of the order comment field. A source order's own comment is not copied across to its mirror. - Once created, the two sides of a pair are independent orders. Nothing in MetaTrader cancels one automatically when the other fills - this script only builds the pair, it does not manage it afterward.
Script · MT4 · v1.0 · Free
About Mirror Pendings To Opposite Side
Mirror Pendings To Opposite Side is an expert advisor (trading robot) for MetaTrader 4. It increases the lot size after a losing trade (martingale) and places pending buy/sell stop or limit orders. It has 7 settings, such as Current symbol only, Magic filter and Mirror magic. MQL source code included.
Files in the download: MirrorPendings.mq4, MirrorPendings.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 |
|---|---|---|
| Current symbol only | false | Restrict to this chart's symbol |
| Magic filter | -1 | Only this magic (-1 means every magic) |
| Mirror magic | -1 | Magic for the new mirror orders (-1 = keep the source's magic) |
| Lot multiplier | 1.0 | Lot size multiplier applied to each mirror |
| Preserve stops | true | Mirror stop loss and take profit as well |
| Max retries | 5 | Attempts before giving up on one mirror |
| Retry wait ms | 500 | Pause between attempts, milliseconds |
How to install
- Download the ZIP from your PolyMaria library and unzip it.
- In MetaTrader 4 open File → Open Data Folder, then go to MQL4 → Experts.
- Copy the .mq4 file(s) there. Put any .mqh files in MQL4 → Include.
- Open the .mq4 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: Breakout · Pending Orders · Martingale · MT4 Script · MQL4 Source Code