Telling EAs apart on a shared account: an ID scheme
Posted: Tue Nov 03, 2026 9:10 am
When several EAs run on the same account, each needs a way to identify its own trades. The magic number field serves this purpose, but conflicts are common when two EAs use the same value or when one EA ignores it.
A practical scheme is to assign magic numbers that encode the strategy and the pair, for example a prefix for the strategy and a suffix for the symbol. This makes logs and reports easier to read.
Every function that counts, modifies or closes positions should filter by both magic number and symbol. An EA that closes all positions on a symbol without checking magic numbers can close trades opened by another EA or by hand.
A worked example: a trailing stop EA attached to EURUSD modifies stops on all EURUSD positions, including one opened manually with a different plan. Filtering by magic number would prevent this.
Netting accounts complicate things further, since positions on the same symbol merge.
How do you organise magic numbers?
A practical scheme is to assign magic numbers that encode the strategy and the pair, for example a prefix for the strategy and a suffix for the symbol. This makes logs and reports easier to read.
Every function that counts, modifies or closes positions should filter by both magic number and symbol. An EA that closes all positions on a symbol without checking magic numbers can close trades opened by another EA or by hand.
A worked example: a trailing stop EA attached to EURUSD modifies stops on all EURUSD positions, including one opened manually with a different plan. Filtering by magic number would prevent this.
Netting accounts complicate things further, since positions on the same symbol merge.
How do you organise magic numbers?