Skip to main content

How to Limit Your Bot to One Trade Per Pair or Strategy

Learn how to limit your EA to one trade per pair or strategy using Count Trades, Select Trades, Symbol filters, Group Numbers, and Magic Numbers so multiple bots can run on the same MT5 account without interfering.

Summary

If you run multiple EAs or multiple strategies on the same MT5 account, you need to make sure each bot only counts and manages its own trades.

Otherwise, one EA may count trades from another pair or strategy and stop trading too early.

Example problem:

Your EURUSD bot sees an open GBPUSD trade 
→ Count Trades thinks a trade is already open
→ EURUSD bot does not open a new trade

To avoid this, use filters such as:

  • Symbol

  • Group Number

  • Magic Number

Also known as: one trade per pair, one trade per symbol, limit trades by pair, Count Trades counts all trades, isolate EA trades, multiple EAs on one account, Magic Number, Group Number, symbol filter.


The simple rule

Use Count Trades before opening a new trade.

Use Select Trades before managing or closing existing trades.

Count Trades = blocks new trades 
Select Trades = manages existing trades

If you only want the EA to check or manage one pair, set the Symbol filter.

If you only want it to check or manage one strategy, use a unique Group Number or Magic Number.


Why this matters

When multiple EAs run on the same MT5 account, they can interfere with each other if they are not separated correctly.

Example:

  • EA 1 trades EURUSD

  • EA 2 trades GBPUSD

  • EA 3 trades XAUUSD

If Count Trades is set too broadly, EA 1 may count trades from EA 2 or EA 3.

That means your EURUSD bot may stop trading because another EA already has a trade open somewhere else.

This is usually not what you want.


Count Trades vs Select Trades

Count Trades

Use Count Trades before an execution block.

Purpose:

Check how many trades or orders already exist before opening a new one.

Typical order:

Run per Candle 
→ Trade Rule
→ Count Trades
→ Buy Now / Sell Now / Pending Order

Use it to prevent:

  • Duplicate trades

  • Too many open positions

  • Multiple entries on the same symbol

  • Multiple entries from the same strategy


Select Trades

Use Select Trades before a management block.

Purpose:

Choose which existing trades or orders should be modified, closed, or managed.

Typical order:

Run per Tick 
→ Select Trades
→ Check Profit/Loss
→ Modify SL/TP / Close Trades / Delete Pending Orders

Use it to manage only specific trades, for example:

  • Only EURUSD trades

  • Only buy trades

  • Only trades from Group 1

  • Only pending orders from one strategy

  • Only trades opened by one EA


The three filters you need to understand

Symbol

The Symbol filter tells the block which trading pair, asset, or instrument to look at.

Examples:

EURUSD 
GBPUSD
XAUUSD
US100
BTCUSD

Important: the symbol name must exactly match the broker’s symbol name in MT5.

Some brokers use suffixes or custom names, for example:

EURUSD 
EURUSD.
EURUSDm
EURUSD.pro
XAUUSD
XAUUSDm
US100.cash

If your broker calls the symbol EURUSDm, then entering EURUSD may not match.

Use the exact symbol shown in MT5 Market Watch.


Group Number

A Group Number is used to separate trades inside your strategy.

Example:

Group 1 = entry trades 
Group 2 = scale-in trades
Group 3 = hedge trades

This is useful when one EA has different trade types and you want to manage them separately.

Example:

Select Trades 
→ Group Number 1
→ Modify SL/TP

This only modifies trades from Group 1.


Magic Number

A Magic Number is the strategy or EA identifier.

Use a unique Magic Number for every EA or strategy instance running on the same MT5 account.

Example:

EURUSD strategy = 7771 
GBPUSD strategy = 7772
XAUUSD strategy = 7773

If two EAs use the same Magic Number, they may treat each other’s trades as their own.

That can cause wrong trade counts, wrong management, or unwanted closes.


How to limit one trade per pair

Goal

Allow only one open EURUSD trade, without blocking trades on other pairs.

Block order

Run per Candle → Trade Rule → Count Trades → Buy Now / Sell Now

Count Trades settings

In the Count Trades block:

Trade type: Buy, Sell, or All Condition: = 0 Advanced Options → Symbol: EURUSD

Use the exact broker symbol.

If your MT5 symbol is EURUSDm, use:

EURUSDm

not:

EURUSD

Screenshot placeholder

[Screenshot placeholder: Count Trades block → Advanced Options expanded → Symbol field highlighted]

Caption:

Use the Symbol field in Count Trades if you only want the EA to count trades on one specific pair, asset, or symbol. The name must exactly match the broker symbol in MT5.


How to limit one trade per strategy

Goal

Allow only one open trade from one specific strategy, even if other EAs are running.

Setup

Give the EA or strategy a unique Magic Number.

Example:

Strategy 1 = 7771 
Strategy 2 = 7772
Strategy 3 = 7773

Then make sure the Count Trades logic only checks trades that belong to that strategy.

If you use Group Numbers, assign the execution block to the correct group and filter by that group where needed.

Example

Run per Candle → Trade Rule → Count Trades: Group 1, Symbol EURUSD, trade count = 0 → Buy Now: Group 1

This means:

Only open a new EURUSD Group 1 trade if there is no existing EURUSD Group 1 trade.

How to manage only one pair

If you want to modify, close, trail, or delete orders only for one pair, use Select Trades.

Block order

Run per Tick → Select Trades → Check Profit/Loss → Modify SL/TP

or:

Run per Tick → Select Trades → Close Trades

or:

Run per Tick → Select Trades → Delete Pending Orders

Select Trades settings

In the Select Trades block:

Trade type: Buy, Sell, or All Advanced Options 
→ Symbol: EURUSD Optional: Group Number

Again, the symbol must exactly match the broker symbol in MT5.

Screenshot placeholder

[Screenshot placeholder: Select Trades block → Advanced Options expanded → Symbol field highlighted]

Caption:

Use the Symbol field in Select Trades if you only want management logic to affect one specific pair, asset, or symbol. This prevents the EA from modifying or closing trades from other symbols.


Practical example: one trade per pair on EURUSD and GBPUSD

You run two EAs on the same account:

EA 1: EURUSD breakout 
EA 2: GBPUSD breakout

Use separate identifiers:

EURUSD EA → Magic Number 7771 
GBPUSD EA → Magic Number 7772

In the EURUSD EA:

Count Trades 
→ Symbol: EURUSD
→ Count = 0 Buy Now / Sell Now

In the GBPUSD EA:

Count Trades 
→ Symbol: GBPUSD
→ Count = 0 Buy Now / Sell Now

Now the EURUSD EA does not block itself because GBPUSD has an open trade.


Practical example: one strategy with two trade groups

You run one EA with two trade types:

Group 1 = main entries 
Group 2 = scale-in entries

For main entries:

Trade Rule 
→ Count Trades: Group 1, Symbol EURUSD, Count = 0
→ Buy Now: Group 1

For scale-ins:

Trade Rule 
→ Count Trades: Group 2, Symbol EURUSD, Count = 0
→ Buy Now: Group 2

For management:

Select Trades: Group 1, Symbol EURUSD 
→ Modify SL/TP

This lets you manage main entries and scale-in entries separately.


Best practice setup

Use this structure when running multiple EAs:

What you want

Use

Separate different EAs

Unique Magic Number

Separate different logic branches inside one EA

Group Number

Separate different pairs/assets

Symbol filter

Prevent duplicate entries

Count Trades

Modify only selected trades

Select Trades

Close only selected trades

Select Trades + Close Trades

Delete only selected pending orders

Select Trades + Delete Pending Orders


Common mistakes

Mistake 1: Count Trades counts all trades

If you do not set a Symbol or Group filter, Count Trades may count more trades than expected.

Result:

Bot does not open a trade because another pair already has one open.

Fix:

Use the Symbol field and, if needed, Group Number or Magic Number.


Mistake 2: Symbol name does not match broker symbol

Bad:

EURUSD

when the broker symbol is:

EURUSDm

Fix:

Use the exact symbol from MT5 Market Watch.


Mistake 3: Select Trades is missing before management

Do not connect management blocks directly if you only want to manage specific trades.

Bad:

Run per Tick → Modify SL/TP

Better:

Run per Tick → Select Trades → Modify SL/TP

Mistake 4: Same Magic Number across multiple EAs

If multiple EAs use the same Magic Number, they can interfere with each other.

Fix:

Use a unique Magic Number for each EA or strategy instance.


Mistake 5: Count Trades is too far away from execution

Place Count Trades close to Buy Now, Sell Now, or Pending Order blocks.

Better:

Trade Rule → Count Trades → Buy Now

Not:

Count Trades → many other branches → Trade Rule → Buy Now

This keeps the execution check close to the actual trade.


Recommended block order

For new trade entries

Run per Candle / Run in Session 
→ Entry Trade Rule → Optional filters
→ Count Trades with Symbol / Group filter
→ Buy Now / Sell Now / Pending Order

For trade management

Run per Tick / Run per Candle → Select Trades with Symbol / Group filter 
→ Check Profit/Loss
→ Modify SL/TP / Close Trades / Delete Pending Orders

Conclusion

If your bot should only take one trade per pair, do not let Count Trades check the whole account.

Use:

Symbol filter + unique Magic Number + Group Number if needed

Use Count Trades before opening new trades.

Use Select Trades before managing existing trades.

Always use the exact broker symbol name from MT5, especially when your broker uses suffixes like .pro, .m, or .cash.

Did this answer your question?