Hi,
How are EAs coded such that they will not interfere with orders that are owned by other EAs? (assuming that is our intention - that is, process only the orders that each EA has initiated)
Is it using the comment? or the magic number? other?
In addition, what if an EA coincidentally is opened with the same differentiating field (e.g. same magic number), how is this handled? do we like generate a new unique magic num for it? or unique comment, if we are using comment?
I am hoping for your input.
Jesus Angeles
create an integer for the Magic number and make SURE there is a different magic number for each EA.
Hi,
How are EAs coded such that they will not interfere with orders that are owned by other EAs? (assuming that is our intention - that is, process only the orders that each EA has initiated)
Is it using the comment? or the magic number? other?
In addition, what if an EA coincidentally is opened with the same differentiating field (e.g. same magic number), how is this handled? do we like generate a new unique magic num for it? or unique comment, if we are using comment?
I am hoping for your input.
Jesus Angeles
//| Make Magic Number |
//+------------------------------------------------------------------+
int MakeMagicNumber( int ExpertID, bool TimeSpecific )
{
int SymbolCode = 0;
int PeriodCode = 0;
int MagicNumber = 0;
//---- Symbol Code
if( Symbol() == "AUDCAD" || Symbol() == "AUDCADm" ) { SymbolCode = 1000; }
else if( Symbol() == "AUDJPY" || Symbol() == "AUDJPYm" ) { SymbolCode = 2000; }
else if( Symbol() == "AUDNZD" || Symbol() == "AUDNZDm" ) { SymbolCode = 3000; }
else if( Symbol() == "AUDUSD" || Symbol() == "AUDUSDm" ) { SymbolCode = 4000; }
else if( Symbol() == "CHFJPY" || Symbol() == "CHFJPYm" ) { SymbolCode = 5000; }
else if( Symbol() == "EURAUD" || Symbol() == "EURAUDm" ) { SymbolCode = 6000; }
else if( Symbol() == "EURCAD" || Symbol() == "EURCADm" ) { SymbolCode = 7000; }
else if( Symbol() == "EURCHF" || Symbol() == "EURCHFm" ) { SymbolCode = 8000; }
else if( Symbol() == "EURGBP" || Symbol() == "EURGBPm" ) { SymbolCode = 9000; }
else if( Symbol() == "EURJPY" || Symbol() == "EURJPYm" ) { SymbolCode = 1000; }
else if( Symbol() == "EURUSD" || Symbol() == "EURUSDm" ) { SymbolCode = 1100; }
else if( Symbol() == "GBPCHF" || Symbol() == "GBPCHFm" ) { SymbolCode = 1200; }
else if( Symbol() == "GBPJPY" || Symbol() == "GBPJPYm" ) { SymbolCode = 1300; }
else if( Symbol() == "GBPUSD" || Symbol() == "GBPUSDm" ) { SymbolCode = 1400; }
else if( Symbol() == "NZDJPY" || Symbol() == "NZDJPYm" ) { SymbolCode = 1500; }
else if( Symbol() == "NZDUSD" || Symbol() == "NZDUSDm" ) { SymbolCode = 1600; }
else if( Symbol() == "USDCAD" || Symbol() == "USDCADm" ) { SymbolCode = 1700; }
else if( Symbol() == "USDCHF" || Symbol() == "USDCHFm" ) { SymbolCode = 1800; }
else if( Symbol() == "USDJPY" || Symbol() == "USDJPYm" ) { SymbolCode = 1900; }
//---- Period Code
if( TimeSpecific )
{
if( Period() == 1 ) { PeriodCode = 10; }
else if( Period() == 5 ) { PeriodCode = 20; }
else if( Period() == 15 ) { PeriodCode = 30; }
else if( Period() == 30 ) { PeriodCode = 40; }
else if( Period() == 60 ) { PeriodCode = 50; }
else if( Period() == 240 ) { PeriodCode = 60; }
else if( Period() == 1440 ) { PeriodCode = 70; }
else if( Period() == 10080 ){ PeriodCode = 80; }
}
else
{
PeriodCode = 0;
}
//---- Calculate MagicNumber
MagicNumber = ExpertID+SymbolCode+PeriodCode;
return(MagicNumber);
}
Thank you spacechimp and Kent.
Is magic number the thing that will resolve this requirement?
Is this 'magic number' useless in the MQL4/MT4 and can therefore be used for any purpose we want, just like identifying EA-instance-owned-orders?
In other words, MT4 doesnt initialize it, doesnt update it, and doesnt touch it in any way? Nothing except our EA touches it?

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hi,
How are EAs coded such that they will not interfere with orders that are owned by other EAs? (assuming that is our intention - that is, process only the orders that each EA has initiated)
Is it using the comment? or the magic number? other?
In addition, what if an EA coincidentally is opened with the same differentiating field (e.g. same magic number), how is this handled? do we like generate a new unique magic num for it? or unique comment, if we are using comment?
I am hoping for your input.
Jesus Angeles