Advertisement IC Markets

Running two EAs on one account, magic numbers and the mess I made without them

Share, develop, and backtest custom MQL4/MQL5 Expert Advisors, Python data-scraping scripts, trading bots, and automated market alert systems.
Post Reply
Fairman
Posts: 3303
Joined: Tue Jul 21, 2026 7:11 am
Location: Abuja

Running two EAs on one account, magic numbers and the mess I made without them

Post by Fairman »

Running two EAs on one account, magic numbers and the mess I made without them

I wanted to run two different strategies on the same account and learned the hard way about magic numbers. Every order an EA places can carry a number that identifies it. If both EAs use the same number, or none, they can start managing each other's trades.

What happened to me was one EA saw an open position and thought it was its own, so it moved the stop and closed it on its own logic. I came back to a pile of trades that didn't match either strategy's rules and it was hard to figure out which did what.

The fix was to give each EA its own magic number and make each one filter positions by its number and symbol before doing anything. I also made sure the risk per trade is calculated per EA, and I put a total open risk limit across both so they can't stack up at the same time on correlated pairs.

If you run more than one, also think about correlation. Two EAs both long EURUSD and GBPUSD is just one big trade in disguise.
It’s Fairman :geek:
Recommended broker for automated trading & scalping IC Markets
Fairman
Posts: 3303
Joined: Tue Jul 21, 2026 7:11 am
Location: Abuja

Re: Running two EAs on one account, magic numbers and the mess I made without them

Post by Fairman »

A simple trick that helped me debug this. I made each EA print a line to the journal tab every time it opens, modifies or closes a trade, with its magic number and a short reason. When something weird happens, I can scroll through the log and see exactly which EA did what and why. Before that I was trying to work it out from the trade history alone, which was almost impossible once both were active on the same symbols.
It’s Fairman :geek:
Fairman
Posts: 3303
Joined: Tue Jul 21, 2026 7:11 am
Location: Abuja

Re: Running two EAs on one account, magic numbers and the mess I made without them

Post by Fairman »

If you use bought EAs rather than ones you wrote yourself, check whether they let you set the magic number in the inputs. Some do not, and two copies of the same EA on different charts can end up with the same number by default. I learned this when I put one EA on two pairs and it started closing trades on the wrong chart. Now the first thing I do with any new EA is check its inputs for a magic number setting.
It’s Fairman :geek:
Post Reply