Synthetic Cross Trader
Some brokers do not list every cross a trader wants - a JPY cross, a metals-versus-minor pairing, anything slightly off the beaten path. The usual workaround is to build the cross synthetically from two symbols the broker does offer: buy EURUSD and buy USDJPY together and you are economically long EURJPY, since EURJPY = EURUSD * USDJPY. The naive version of this idea treats the two legs as if they were one trade. They are not. This is two separate broker positions, sent one after another, and every seam between them is a place something can go wrong: the second leg can be rejected or requoted while the first is already live and exposed alone, the two fills land at slightly different times and prices so the synthetic entry is never exactly the theoretical rate implied by the quotes at one instant, and once both legs are open either one can close independently of the other - a broker stop-out, a manual close from the terminal, a connection drop partway through this EA's own attempt to close both legs together - leaving the survivor open with no hedge and no plan. This EA does two things about that instead of ignoring it. First, on entry it sends Leg A, and only on a confirmed fill does it attempt Leg B; if Leg B cannot be filled after its retry budget, Leg A is closed back out immediately rather than left running alone. Second, on every tick it checks every open synthetic position for a leg that vanished on its own - and if it finds one, it alerts loudly and, if enabled, flattens the surviving leg immediately. Neither of these makes the pair atomic. They bound how long a single-leg exposure can sit unmanaged to one tick and one retry budget, which is the honest amount of protection a two-order construction can actually offer. The entry/exit signal itself - a fast/slow SMA crossover computed on the reconstructed synthetic price - is deliberately simple. The point of this submission is the two-leg execution and monitoring discipline around it, not a claim to trading edge. Notes and limitations - This is not an atomic two-leg order. Every risk described in the header comment of the source file is real and cannot be fully removed by software running on top of two independent broker order sends - only bounded in how long it can go unnoticed and how it is contained once found. Do not run this unattended on a live account without understanding that. - Runs at most one synthetic position at a time by design; it does not pyramid or scale into the same cross. - The synthetic entry price is a reconstruction from two live quotes, not a tradable price any exchange or broker actually offers - treat it as an approximation, not an exact fill guarantee. - Requires a hedging-style account. It opens Leg A and Leg B as independent positions and does not attempt to net them against any other position on the same underlying symbol. - If InpAutoFlattenOrphanLeg is off, an orphaned leg is only alerted on, never closed automatically - left running, it is an ordinary unhedged single-symbol position with no stop-loss of its own.
Expert advisor · MT5 · v1.0 · Free
About Synthetic Cross Trader
Synthetic Cross Trader is an expert advisor (trading robot) for MetaTrader 5. It has 14 settings, such as Leg a symbol, Leg b symbol and Cross is product. MQL source code included.
Files in the download: SyntheticCrossTrader.ex5, SyntheticCrossTrader.mq5, SyntheticCrossTrader.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 |
|---|---|---|
| Leg a symbol | EURUSD | First leg symbol |
| Leg b symbol | USDJPY | Second leg symbol |
| Cross is product | true | true: synthetic = LegA * LegB (e.g. EURJPY=EURUSD*USDJPY). false: synthetic = LegA / LegB |
| Synthetic name | EURJPY(synthetic) | Label only, used in logs/comments/tickets |
| Leg a lots | 0.10 | Lot size sent on Leg A per synthetic position |
| Leg b lots | 0.10 | Lot size sent on Leg B per synthetic position |
| Fast ma period | 10 | Fast SMA period on the reconstructed synthetic close |
| Slow ma period | 30 | Slow SMA period on the reconstructed synthetic close |
| Max history bars | 200 | How many synthetic closes to keep for the moving averages |
| Magic | 26601 | Magic number tagging both legs of this EA's own trades |
| Slippage pips | 5 | Slippage tolerance per leg |
| Max retries | 5 | Order-send/close attempts before giving up on a leg |
| Auto flatten orphan leg | true | Close the surviving leg immediately if its partner disappears |
| Alert on orphan leg | true | Alert() whenever an orphaned leg is detected |
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: EURUSD · USDJPY · MT5 Expert Advisor · MQL5 Source Code