Magic Number Registry
Magic numbers are usually picked by hand, one EA at a time, with no record of which numbers are already spoken for. On a terminal running several EAs at once, or across a team sharing EAs on the same account, two of them eventually end up on the same magic number - and everything downstream that filters "my own orders" by magic number quietly starts touching someone else's trades. This script is a planning tool, not a live scanner: it never reads open orders or trade history. It only reads and writes its own registry file, one row per EA, holding a name, a start magic, a range size, an end magic, the date it was registered and a free-text note. Register mode either allocates the next free block automatically (right after the highest end magic already registered) or checks a specific requested start against every existing range and refuses outright if it would overlap - it never silently reassigns a colliding request to somewhere else. Check mode looks up a single magic number and reports which registered EA (if any) owns it, including the case where more than one overlapping entry claims it, which means the registry itself already has a collision worth fixing. Whether an EA actually uses the magic numbers it was allocated is up to whoever wires the resulting InpMagicStart-style value into that EA's own input - the registry has no way to enforce that from outside, and does not claim to. Notes and limitations - The registry is a plain CSV that can be hand-edited. A hand-edited overlap between two ranges is detected and reported by Check mode (it reports every matching entry, not just the first), but Register mode only actively prevents a NEW overlap - it does not repair one that already exists in the file. - Registering the same EA name twice is refused; release the existing entry first if it genuinely needs to be re-registered with a different range. - This tool has no connection to live trading. It does not verify that an EA is actually using the magic numbers registered for it, and cannot - that link only exists inside the EA's own code. - A malformed or blank line in a hand-edited registry file is skipped silently when the file is loaded, on the basis that a partially-edited file should not crash the tool, but this means a badly mistyped row can disappear from the registry the next time anything is registered or released (which rewrites the whole file from the entries it could parse).
Script · MT4 · v1.0 · Free
About Magic Number Registry
Magic Number Registry is a script for MetaTrader 4. It can alert you with a pop-up, sound, email or push message. It has 7 settings, such as Mode, Registry file and Ea name. MQL source code included.
Files in the download: MagicNumberRegistry.mq4, MagicNumberRegistry.txt.
Settings
| Setting | Default | What it does |
|---|---|---|
| Mode | ModeList | Mode |
| Registry file | MagicNumberRegistry.csv | Registry filename in MQL4\Files |
| Ea name | Register/Release: Expert Advisor name | |
| Range size | 100 | Register: how many magic numbers to reserve |
| Preferred start | 0 | Register: specific start magic (0 = auto-allocate after the last range) |
| Magic to check | 0 | Check: magic number to look up |
| Notes | Register: free-text note stored with the entry |
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 → Scripts.
- 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 script onto a chart to run it once.
Tags: Alerts · MT4 Script · MQL4 Source Code