Use this article if your EA has multiple entries, different targets, scale-ins, or separate management rules.
Common examples:
one entry with a 10 pip target and another entry with a 20 pip target
one main entry and one scale-in entry
one trade that takes partial profit and another trade that runs longer
one EA that opens multiple trade types
several EAs running on the same MT5 account
Also known as: project properties, multiple entries, different targets, one entry not opening, Group Number, Magic Number, Count Trades blocking another entry, trade groups, scale-in trades, multi-entry strategy, TP1 TP2, one branch suppressing another.
Summary
Group Numbers and Magic Numbers solve different problems.
A Group Number separates trades inside one EA.
A Magic Number separates different EAs or strategy systems on the same MT5 account.
If you have two entries inside the same bot, for example one with a 10 pip target and one with a 20 pip target, you usually need Group Numbers, not different Magic Numbers.
If you run two separate EAs on the same MT5 account, you need different Magic Numbers so they do not manage each other’s trades.
Group Number vs Magic Number
Group Number = trade-level identifier
A Group Number is used inside one EA to label different types of trades.
Example:
Group 1 = first entry with 10 pip target
Group 2 = second entry with 20 pip target
Group 3 = scale-in entry
Group 4 = hedge entry
This lets you manage each group separately.
Example:
Select Trades → Group Number 1 → Modify SL/TP
This only manages trades from Group 1.
Use Group Numbers when different trades inside the same EA need different targets, stop-loss rules, trailing rules, or close rules.
Magic Number = EA/system-level identifier
A Magic Number identifies the EA or trading system that opened the trade.
MetaTrader 5 uses Magic Numbers to separate trades opened by different Expert Advisors.
Example:
Trend EA = Magic Number 7777
Breakout EA = Magic Number 8888
Scalping EA = Magic Number 9999
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 stop-loss updates, wrong closes, or one EA managing trades from another EA.
Use different Magic Numbers when running multiple independent EAs or strategy systems on the same MT5 account.
Simple rule
Use Group Numbers to separate entries inside one EA.
Use Magic Numbers to separate different EAs on the same MT5 account.
Use Count Trades before opening new trades.
Use Select Trades before managing existing trades.
Short version:
Count Trades = blocks or allows new entries
Select Trades = chooses existing trades to manage
Group Number = separates trades inside one EA
Magic Number = separates different EAs/systems
Where to set the Magic Number
You can set the Magic Number in Project Properties.
You can also change the Magic Number in MetaTrader 5 when attaching the EA to a chart or running a backtest.
Best practice:
Set a unique Magic Number for every EA or strategy instance you run on the same MT5 account.
Example:
System 1 → 7777
System 2 → 8888
System 3 → 9999
System 4 → 6666
Do not leave several independent EAs running with the same Magic Number unless you intentionally want them to see and manage the same trades.
Project Properties overview
Project Properties define how your EA is identified, described, and exported.
Main fields:
Project Title
The name of your bot.
Use a clear name so you can recognize the strategy later.
Example:
EURUSD Breakout TP1 TP2
Copyright Line
Add your name, brand, or company.
Useful if you plan to share or publish the EA.
Website Link
Add a link connected to the bot.
Many users link to documentation, a Notion page, a Google Doc, or an internal strategy note.
Version Number
Mostly useful when publishing or tracking versions.
For normal testing, this is optional.
Magic Number
The EA/system identifier.
Use a unique Magic Number for each independent EA or strategy instance.
Trading Account Number
This can be used to lock the exported EX5 file to a specific MT5 trading account.
If a trading account number is added before downloading, the EX5 file only works on the MT5 account that matches that number.
This is not the same as a Magic Number.
Magic Number = separates trades by EA/system
Trading Account Number = restricts where the exported EA can run
Read the full on Trading Account Number Encryption here: https://docs.profectus.ai/en/articles/14653497-account-number-lock
Description
A short explanation of what the EA does.
Use this to document the strategy logic, timeframe, symbol, or version notes.
Example: two entries with different targets inside one EA
This is the most common setup users ask about.
Goal:
Open two entries from the same strategy signal.
Entry 1 targets 10 pips
Entry 2 targets 20 pips
Both entries should be able to open from the same setup.
Correct setup:
Entry 1 uses Group Number 1 and TP = 10 pips
Entry 2 uses Group Number 2 and TP = 20 pips
Example structure:
Run per Candle
→ Entry condition
→ Count Trades for Group 1 = 0
→ Buy Now or Sell Now with Group Number 1 and TP 10 pips
Run per Candle
→ Same entry condition
→ Count Trades for Group 2 = 0
→ Buy Now or Sell Now with Group Number 2 and TP 20 pips
This allows each entry to be counted and managed separately.
Why one entry may appear and the other does not
If one entry opens but the other does not, the most likely reason is that one branch is suppressing the other.
This usually happens because Count Trades is too broad.
Example problem:
You want two entries:
Entry A = TP 10 pips
Entry B = TP 20 pips
But both branches use:
Count Trades → all trades = 0
What happens:
Entry B opens first.
Now there is already one open trade.
Entry A checks Count Trades.
Count Trades sees the open trade from Entry B.
Entry A does not open.
The EA is doing what you told it to do. The logic is just too broad.
How to fix branch suppression
Use one of these two setups.
Option 1: Use one shared Count Trades check before both entries
Use this if both entries should always open together from the same setup.
Example:
Run per Candle
→ Entry condition
→ Count Trades: total setup trades = 0
→ Entry 1: Group 1, TP 10 pips
→ Entry 2: Group 2, TP 20 pips
This means:
If no trade from this setup exists yet, both entries are allowed to open.
Use this when TP1 and TP2 are part of the same entry idea.
Option 2: Use separate Count Trades checks per Group Number
Use this if each entry should be controlled independently.
Example:
Branch 1:
Run per Candle
→ Entry condition
→ Count Trades: Group 1 = 0
→ Entry 1: Group 1, TP 10 pips
Branch 2:
Run per Candle
→ Entry condition
→ Count Trades: Group 2 = 0
→ Entry 2: Group 2, TP 20 pips
This means:
Group 1 only checks whether Group 1 already has a trade.
Group 2 only checks whether Group 2 already has a trade.
Group 1 does not block Group 2.
Group 2 does not block Group 1.
This is usually the cleanest setup for multi-entry strategies.
How to manage each target separately
Once the trades are open, use Select Trades with the correct Group Number.
Example:
Manage the 10 pip target trade
Select Trades → Group Number 1
→ Check Profit/Loss
→ Close Trades / Modify SL/TP
Manage the 20 pip target trade
Select Trades → Group Number 2
→ Check Profit/Loss
→ Close Trades / Modify SL/TP
This prevents the management logic for TP1 from affecting TP2.
Example: TP1 closes early, TP2 trails longer
Goal:
Group 1 closes at 10 pips
Group 2 stays open and trails stop loss after 20 pips
Entry logic:
Entry condition
→ Entry 1: Group 1, TP 10 pips
→ Entry 2: Group 2, TP 20 pips or no fixed TP
Management logic for Group 1:
Run per Candle or Run per Tick
→ Select Trades: Group 1
→ Check Profit/Loss: profit >= 10 pips
→ Close Trades
Management logic for Group 2:
Run per Candle or Run per Tick
→ Select Trades: Group 2
→ Check Profit/Loss: profit >= 20 pips
→ Modify SL/TP
This creates a basic TP1 / TP2 structure.
Group 1 is the shorter target.
Group 2 is the runner.
Example: one EA with main entry and scale-in entry
Goal:
One EA has two different entry types.
Group 1 = main entry
Group 2 = scale-in entry
Main entry:
Entry condition A
→ Count Trades: Group 1 = 0
→ Buy Now / Sell Now with Group Number 1
Scale-in entry:
Entry condition B
→ Count Trades: Group 2 = 0
→ Buy Now / Sell Now with Group Number 2
Management:
Select Trades: Group 1
→ Manage main entry
Select Trades: Group 2
→ Manage scale-in entry
This keeps the two trade types separate even though they come from the same EA.
Example: two separate EAs on one MT5 account
Use Magic Numbers here.
Example:
EA 1 = EURUSD breakout = Magic Number 7777
EA 2 = XAUUSD pullback = Magic Number 8888
If both EAs use the same Magic Number, their management logic may overlap.
Example problem:
EA 1 has a rule:
When a trade reaches 1% profit, move stop loss to breakeven.
EA 2 opens a trade.
If both EAs use the same Magic Number, EA 1 may see EA 2’s trade as part of its own system and try to manage it.
Fix:
Give each EA a unique Magic Number.
When to use what
Goal | Use |
Separate two entries inside one EA | Group Number |
Set different targets inside one EA | Group Number |
Manage TP1 and TP2 separately | Select Trades by Group Number |
Prevent one entry branch from blocking another | Count Trades by Group Number |
Separate multiple EAs on one MT5 account | Magic Number |
Stop one EA from managing another EA’s trades | Unique Magic Number |
Prevent duplicate entries | Count Trades |
Manage existing trades | Select Trades |
Close, trail, or modify only one trade cohort | Select Trades by Group Number |
Count Trades vs Select Trades
Count Trades
Use Count Trades before opening a new trade.
Purpose:
Check how many trades or orders already exist before allowing another entry.
Example:
Entry condition
→ Count Trades: Group 1 = 0
→ Buy Now / Sell Now
Use Count Trades to prevent:
duplicate entries
too many open trades
repeated entries from the same branch
one group opening more trades than intended
Important:
If Count Trades is too broad, it may block entries that should be allowed.
Select Trades
Use Select Trades before managing existing trades.
Purpose:
Choose which trades or orders the following management blocks should affect.
Example:
Run per Tick
→ Select Trades: Group 1
→ Check Profit/Loss
→ Modify SL/TP
Use Select Trades before:
Close Trades
Modify SL/TP
Delete Orders
Check Profit/Loss
Important:
If Select Trades is too broad, one management branch may modify the wrong trade.
Best-practice setup for multiple entries with different targets
Use this structure:
Give each entry its own Group Number.
Set the target inside the matching Buy Now, Sell Now, or Pending Order block.
Use Count Trades filtered by Group Number before each entry branch.
Use Select Trades filtered by Group Number before each management branch.
Use a unique Magic Number if this EA runs next to other EAs on the same MT5 account.
Test in MT5 Visual Mode and check whether both entries open as expected.
Example:
Entry 1:
Group Number 1
TP 10 pips
Count Trades checks Group 1 only
Entry 2:
Group Number 2
TP 20 pips
Count Trades checks Group 2 only
Management 1:
Select Trades Group 1
Manage TP1 trade only
Management 2:
Select Trades Group 2
Manage TP2 trade only
Common mistakes
Mistake 1: Using Magic Numbers for entries inside the same EA
Magic Numbers are for separating EAs or strategy systems.
They are not the right tool for separating TP1 and TP2 inside the same bot.
Use Group Numbers for that.
Mistake 2: Using the same Group Number for different targets
If both entries use the same Group Number, the EA treats them as the same trade cohort.
That makes it harder to manage them separately.
Better:
Group 1 = TP 10
Group 2 = TP 20
Mistake 3: Count Trades checks all trades
If Count Trades checks all trades, one branch can block another.
Example:
Entry 1 opens.
Entry 2 checks whether all trades = 0.
The answer is now false, because Entry 1 already opened.
Fix:
Filter Count Trades by Group Number, or use one shared Count Trades check before splitting into both entries.
Mistake 4: Select Trades is missing before management
Management blocks need to know what to manage.
Bad:
Run per Tick
→ Modify SL/TP
Better:
Run per Tick
→ Select Trades: Group 1
→ Modify SL/TP
Use Select Trades before management actions.
Mistake 5: Management logic targets the wrong group
If your TP1 management branch does not filter Group 1, it may affect TP2 as well.
Fix:
Use Select Trades with the correct Group Number before Close Trades, Modify SL/TP, or Delete Orders.
Mistake 6: Two EAs use the same Magic Number
If two different EAs use the same Magic Number, they may manage each other’s trades.
Fix:
Use a different Magic Number for each independent EA or strategy instance.
Mistake 7: Count Trades is too far away from execution
Place Count Trades close to the Buy Now, Sell Now, or Pending Order block.
Good:
Entry condition
→ Count Trades
→ Buy Now
Risky:
Count Trades
→ many other blocks
→ entry logic
→ Buy Now
Keep the duplicate-entry check close to the execution block.
Still not enough about trading groups/ grouping trades? Check out this video about the infamous turtle strategy in which group numbers are playing a highly crucial role. Check it out for a hands-on example:
Debug checklist: one entry opens, the other does not
If one entry appears and the other does not, check this:
Are both entry blocks connected to the correct true path?
Do both branches receive the same entry signal?
Does each entry have its own Group Number?
Is Count Trades filtered by Group Number?
Is one branch checking all trades instead of only its own group?
Does one branch open first and then block the other?
Are both execution blocks set with the intended TP?
Is the trade type correct: Buy Now, Sell Now, Buy Pending Order, or Sell Pending Order?
Is the MT5 Journal showing an execution error, margin issue, invalid stops, or rejected order?
Did you test in MT5 Visual Mode?
If you are not sure, share the project link and explain which entry should open first, which target each entry should use, and which trade is missing.
Conclusion
Use Group Numbers when you want to separate trades inside one EA.
Use Magic Numbers when you want to separate different EAs on the same MT5 account.
If one entry opens and another does not, the issue is often not the target setting. It is usually the logic before execution.
Most often, Count Trades is checking too broadly and one branch blocks the other.
For multiple entries with different targets, give each entry its own Group Number and make sure Count Trades and Select Trades use the matching group.



