Running Multiple Expert Advisors on One Trading Account

Two strategies, one account, and a forum answer that says to give each program a different magic number. That is where most of these setups begin, and it is also where a good many of them quietly go wrong.

The magic number is real and it does matter. What it is not is a boundary the terminal polices. Every mechanism described below was read in the MetaQuotes documentation rather than taken from a trading blog.

Key takeaways

  • The magic number is a field each expert advisor writes onto its own trade request. Nothing in the platform reserves a value or rejects a duplicate.
  • The account’s position-accounting mode decides whether the setup is possible at all. Under netting, only one position can exist for one symbol.
  • A collision raises no error. It appears as one program closing or modifying a trade that another one opened.
  • MetaQuotes publishes no maximum number of expert advisors. Each runs in its own thread, so the practical ceiling is charts and machine resources.
  • One advisor per chart is a workspace limit, not an account limit.
  • Margin, equity and the stop out are computed across everything at once, however carefully the orders are kept apart.

What Running Several Expert Advisors Actually Requires

Three conditions decide whether several automated strategies can share one account. They are worth taking in the order that determines the outcome, which is not the order most guides use.

The first is the position-accounting mode of the account itself. It is settled before any program is attached, and it can make the whole arrangement impossible no matter how the programs are configured.

The second is the chart. An expert advisor is attached to one chart and reads only that chart’s events, so the number of programs running is bounded by the number of charts open.

The third is a convention for telling one program’s orders from another’s. This is the magic number, and it is the part almost every guide opens with.

Putting it third is deliberate. A carefully assigned set of magic numbers on a netting account solves nothing, because the thing they are meant to separate does not exist there in the first place.

The Magic Number Is a Field, Not a Fence

In MetaTrader 5 a trade request is assembled in a structure called MqlTradeRequest. The MetaQuotes reference lists its members, and one of them is declared as a ulong named magic, described as the expert advisor identifier.

That declaration is the whole of it. The value is written by the program onto its own request, sent to the server, and stored against the resulting order and deal.

Two things follow, and both are the opposite of how the field is usually described. Nothing reserves a number to one program, so two advisors can carry the same value with no complaint from the terminal.

And nothing obliges a program to read the field either. An advisor that selects orders to close without filtering on its own magic number will happily act on trades it never opened.

The separation, in other words, lives in the code of the programs rather than in the platform. It holds only while every program on the account observes it, which is why an advisor bought from a vendor deserves a check on this point before it is put beside another one.

Calling the field a fence, a boundary or a lock inverts where the responsibility sits. It is a label, and labels do not enforce anything on their own.

Where Netting Silently Defeats the Whole Setup

MetaTrader 5 accounts carry a margin mode, and the MetaQuotes account documentation enumerates the possible values. One of them is ACCOUNT_MARGIN_MODE_RETAIL_NETTING, used for over-the-counter markets, under which only one position can exist for one symbol.

Read that against a setup with two advisors on the same instrument. There are not two positions for the magic numbers to distinguish, because the account only ever holds one.

If one program is long a lot of a pair and a second sells six tenths of a lot, the account does not show a long and a short. It shows a single position of four tenths.

The orders and deals still carry their separate identifiers, so the history remains readable. The exposure does not: neither strategy now holds the position it believes it holds.

The mode that keeps them apart is ACCOUNT_MARGIN_MODE_RETAIL_HEDGING, under which separate positions on one symbol coexist. Which mode an account uses is set by the broker, and the distinction is covered in more depth in the guide to netting and hedging account types.

This is the precondition to establish first, and it is the one no competitor page on this topic raises at all.

QuestionNetting accountHedging account
Positions per symbolOne, as documentedSeveral, held separately
Two advisors, same instrumentShare a single position; opposing orders offsetEach keeps its own position
What the magic number still doesTags orders and deals in the historyTags orders, deals and the position itself
Two advisors, different instrumentsIndependent, one position eachIndependent

One Expert Advisor Per Chart, and What That Really Limits

An expert advisor is attached to a chart, and the MetaQuotes documentation on program running states that a program receives only the events of the chart it runs on. Five strategies therefore mean five charts.

That is a constraint on the workspace, not on the account. The account has no idea how many charts are open; it sees orders arriving.

The same documentation is unusually specific about what running several programs costs. Each script, service and expert advisor runs in its own separate thread, and the number of threads for expert advisors equals the number of expert advisors.

It adds that a looped expert advisor cannot break the running of other programs. The isolation is real, and it is the reason no fixed maximum is published.

Indicators behave differently and are worth knowing about here. All indicators calculated on one symbol share a single thread, and an infinite loop in one of them will stop every other indicator on that symbol.

So the shared-resource hazard on a busy terminal sits with indicators rather than with the advisors themselves. The documentation also notes a start delay of no more than five seconds while an advisor’s trading environment and history are prepared.

Because all of this depends on a machine staying awake and connected, traders running several programs at once commonly move the terminal onto a forex VPS rather than a desktop that sleeps.

How a Collision Actually Shows Up

The most useful thing to know about a magic number collision is that nothing announces it. There is no warning dialog, no journal entry and no duplicate check anywhere in the chain.

What appears instead is behaviour that makes no sense from inside either strategy. A position closes that its own program did not close, or a stop moves to a level that program would never have chosen.

On a netting account the symptom is different again: volume simply disappears, because an opposing order from the other program reduced a position rather than opening one.

Diagnosis is retrospective. The trade history holds the identifier on every order and deal, so the sequence can be reconstructed afterwards by matching them, which is exactly when most people first look.

That delay is the practical cost. A conflict that would take a minute to prevent is usually found only once it has produced a result worth investigating.

The Numbers Competitors Publish That No Source Supports

Two figures circulate widely on this topic. Neither appears in any MetaQuotes document, and this page does not repeat either of them as fact.

The first is a claim that the terminal permits some fixed maximum number of expert advisors, most often given as one hundred. No such limit is stated in the documentation.

What the documentation does say is more useful anyway. Because thread count tracks program count and a looped advisor cannot stall the others, the ceiling that binds in practice is the number of charts a person can manage and the resources of the machine underneath them.

The second is a pair of configuration thresholds, typically expressed as keeping combined risk below two per cent and free margin above three hundred per cent. These are presented as settings the setup requires.

They are not requirements. No platform documentation and no regulator rule fixes either number, and no threshold of that kind exists to be complied with.

They may still be a reasonable personal preference, and that is the distinction worth holding onto. A number an author chose is not a number the system imposes, and treating the two the same way is how a preference hardens into a rule that nobody can trace.

What Aggregates at the Account Level

Each strategy is normally developed and tested on its own. The account it lands on does not preserve that separation.

Margin is required against total exposure, equity moves with every open position at once, and the forced-closing condition is evaluated on the account as a whole. The mechanics of that threshold are set out under stop out levels.

This is what makes the combination different from its parts. Two strategies can each be sound in isolation and still be adverse at the same moment, and it is that simultaneity, not the average of their results, that the account experiences.

The risk that matters is therefore a joint one. A per-strategy figure says nothing about how the pair behaves on the day both are wrong, particularly when they trade related instruments and their drawdowns arrive together.

It follows that a separate test of each program leaves the important question unanswered. Anyone backtesting a strategy intended to run alongside another needs the combined equity curve, not two individual ones read side by side.

Who This Page Is Not For

This page explains what the platform enforces and what it leaves to the programs. It does not evaluate any expert advisor, and it takes no view on whether automated trading suits a particular person.

It is also not a setup walkthrough for a named product. Vendors document their own inputs, and those instructions sit on top of the mechanisms described here rather than replacing them.

The mechanisms themselves are MetaTrader ones. Other platforms organise automation differently, and readers working elsewhere will find the comparison in the guide to cTrader more relevant than the detail above.

Frequently Asked Questions

Can I run two expert advisors on the same chart?

No. An advisor occupies the chart it is attached to, and the MetaQuotes documentation describes a program as receiving only the events of the chart it runs on. Running several means opening several charts, which is a limit on the workspace rather than on the account.

What happens if two expert advisors use the same magic number?

Nothing at the moment it happens, which is the difficulty. The value is a field on the trade request and the platform does not test it for uniqueness. The consequence appears later, when one program treats orders belonging to the other as its own and closes or modifies them.

Do magic numbers work on a netting account?

They continue to tag orders and deals, so the history stays readable. They cannot separate exposure. MetaQuotes defines the retail netting mode as one in which only one position can exist for one symbol, so two advisors trading that symbol are sharing a single position whatever identifiers they write.

How many expert advisors can one terminal run?

MetaQuotes publishes no maximum. The documentation states that each advisor runs in its own thread and that the number of threads equals the number of advisors, so the binding limits are open charts and the resources of the machine. Figures such as a hundred circulate widely but are not in the documentation.

Is there a safe number of expert advisors to run at once?

No documented one exists, and no platform or regulator sets a threshold for combined risk or free margin. The widely repeated two per cent and three hundred per cent figures are individual preferences rather than requirements. What does apply is that margin and the stop out are calculated across the whole account at once.

Sources checked 1 August 2026: MetaQuotes, MQL5 Reference, MqlTradeRequest structure — for the declaration of magic as a ulong member described as the expert advisor identifier. MetaQuotes, MQL5 Reference, Account Information and the ENUM_ACCOUNT_MARGIN_MODE enumeration — for ACCOUNT_MARGIN_MODE_RETAIL_NETTING, used for over-the-counter markets and defined so that only one position can exist for one symbol, and for ACCOUNT_MARGIN_MODE_RETAIL_HEDGING. MetaQuotes, MQL5 Reference, Program Running — for each expert advisor running in a separate thread, the number of threads equalling the number of expert advisors, a looped advisor not breaking other programs, all indicators on one symbol sharing a single thread, and the start delay of no more than five seconds. MetaQuotes, MQL5 Reference, Client Terminal Events — for a program receiving only the events of the chart it runs on. No maximum number of expert advisors, and no combined-risk or free-margin threshold, appears in any of those documents; figures of that kind on this page are identified as unsourced claims rather than repeated as fact.

Disclaimer: This article is educational only, is not investment advice, and is not a recommendation to use automated trading, any particular expert advisor, or any broker or platform. Automated systems can fail, conflict with one another and lose money without intervention, and past testing results do not indicate future outcomes. Trading leveraged foreign exchange and contracts for difference carries a high risk of losing money rapidly.

Leave A Reply

Your email address will not be published.