Magic number manager OrderByMagic EA
- Indicatori
- Minh Vuong Pham
- Versione: 1.1
OrderByMagic is a display-only Indicator for MT5. It reads all open positions on your account and shows them grouped by Magic Number directly on the chart — updated every 2 seconds. It never opens, closes, or modifies any trade.
The Magic Number collision problem
Every EA stamps a Magic Number on the orders it opens so it can identify and manage them later. When you run multiple EAs at the same time, each one must have a unique Magic Number. In practice this often goes wrong:
• You attach a new EA and forget to change its default Magic Number (commonly 0 or 12345) — it silently collides with an existing strategy.
• You attach the same EA to two charts (e.g. EURUSD M15 and GBPUSD H1) with the same Magic Number.
• After a VPS reboot you re-attach an EA and accidentally type the wrong number in the input dialog.
• You use a purchased EA with a hardcoded Magic Number that clashes with your own.
⚠ A collision means two EAs may manage each other's orders — closing or modifying trades they did not open. This causes unpredictable losses.
Why the MT5 Trades tab is not enough
The built-in Trades tab shows all positions in a flat list. It does not group by Magic Number, has no colour-coding per strategy, and requires manually adding the "Magic" column. Scanning 20+ positions across 5 strategies is slow and error-prone. OrderByMagic EA puts the grouped view directly on your price chart so you never have to leave it to audit positions.
| Situation | Without this EA | With this EA |
| Running 3 EAs on 3 pairs | Hard to tell which orders belong to which EA | Each EA's orders in a separate labelled block |
| Re-attaching EA after VPS reboot | Risk of typing wrong Magic Number in the dialog | See all active Magic Numbers before you type |
| Testing a new EA alongside live EAs | New EA may use Magic 0 and interfere with manual trades | Confirm Magic 0 is free before starting |
| Parameter | Default | Description |
| UpdateIntervalSeconds | 2 | Refresh rate in seconds |
| Corner | 0 | Display position: 0 = top-left, 1 = top-right |
| XDistance / YDistance | 10 / 20 | Pixel offset from the chosen corner |
| FontSize | 9 | Text size. Reduce to 7–8 if display overflows vertically |
| HeaderColor | Yellow | Color of the section header and divider lines |
| MagicColor | Aqua | Color of the ╔═══ MAGIC: xxx ═══ group headers |
| BuyColor / SellColor | Blue / Red | Colors for BUY and SELL position lines |
| TextColor | White | Color of general information text |
Positions are sorted by Magic Number. Each group shows:
• Group header → ╔═══ MAGIC: 10001 (2 orders) ═══
• Per position: Ticket · Type (BUY/SELL) · Symbol · Lot size · Open price · Current price · SL / TP · Open time
═══════════════════════════════════════
LỆNH THEO MAGIC NUMBER
2025.11.15 09:42:17 Total: 5 orders
═══════════════════════════════════════
╔═══ MAGIC: 10001 (2 orders) ═══
║ [1] Ticket: 1234567890
║ BUY EURUSD 0.10 lot
║ Open: 1.08342 Now: 1.08511
║ SL: 1.07900 TP: 1.09000
║ Opened: 2025.11.15 08:12
╚════════════════════════════════════
╔═══ MAGIC: 20050 (3 orders) ═══
║ [1] Ticket: 1234567895
║ SELL GBPUSD 0.20 lot
║ Open: 1.26800 Now: 1.26540
║ SL: --- TP: 1.25000
╚════════════════════════════════════
