Magic numbers

 

Hi,

I have a question about magic numbers. I have my own EA which had unwanted behaviour one day which resulted in large losses, but I wasn't able to repeat this to make sure what the reason was.


My question is - if I have 2 orders open at once, one on let's say EURUSD and the other on GBPUSD and these orders have the same magic number, but I recongize them by Magic Number AND Currency Pair - could this cause any problems? The checking code is 100% correct, I have checked a hundred times, however, I am asking particularly about magic numbers, whether there is anything that could happen if there are 2 same magic numbers on orders with different pairs.


Thank you.

 
Fromin:

Hi,

My question is - if I have 2 orders open at once, one on let's say EURUSD and the other on GBPUSD and these orders have the same magic number, but I recongize them by Magic Number AND Currency Pair - could this cause any problems?

NO

 
Fromin:

[...] My question is - if I have 2 orders open at once, one on let's say EURUSD and the other on GBPUSD and these orders have the same magic number, but I recongize them by Magic Number AND Currency Pair - could this cause any problems? The checking code is 100% correct, I have checked a hundred times, however, I am asking particularly about magic numbers, whether there is anything that could happen if there are 2 same magic numbers on orders with different pairs.

In theory, filtering by symbol is just as good as filtering by magic if it is known that no two concurrently running EA's will use the same symbol. But that is not the only issue with running concurrent EA's - both experts must be designed to "share" resources properly (share the Trade thread, share the account's free margin, etc.).
 
qjol:


i have too same magic number on different pairs ... if your code is correct and you check all time Pair and MagicNumber .. no Problem!
 
You must count down when handling multiple orders (multiple EA's). Do you check select return code
for(int pos = OrdersTotal()-1; pos >= 0 ; pos--) if (
    OrderSelect(pos, SELECT_BY_POS)             // Only my orders w/
&&  OrderMagicNumber() == Magic.Number          // my magic number
&&  OrderSymbol()      == Symbol() ){           // and period and symbol
Reason: