Magic Number

 

Hi All

 Really the first question I have.  Just started learning MQL4.   I'm not really sure what the magic number on the inputs for these EAs do.  I looked it up but still confused.  Can someone throw me a quick dumbed down answer?

 

 

THanks Harry  

 

Hi Harry

You use the MagicNumber as a unique identifier for orders. So when you run the EA, every order will be given the same MagicNumber (say 12345). The EA will then know which orders belong to it.

So lets say you have the same EA running on 2 different symbols/charts. If you used the same MagicNumber on both, the EAs would get confused as both EAs will try to manage orders on both charts. But if one EA uses a MagicNumber of 1234 and the other uses 5678, each EA will know which orders belong to it.

Cheers
Stu

 
Stuart Browne:

Hi Harry

You use the MagicNumber as a unique identifier for orders. So when you run the EA, every order will be given the same MagicNumber (say 12345). The EA will then know which orders belong to it.

So lets say you have the same EA running on 2 different symbols/charts. If you used the same MagicNumber on both, the EAs would get confused as both EAs will try to manage orders on both charts. But if one EA uses a MagicNumber of 1234 and the other uses 5678, each EA will know which orders belong to it.

Cheers
Stu

Ahhhh,   Thanks Stuart makes sense now.  I thought it was something along those lines, but was not sure.

 

thanks again much appreciated

Harry J 

 
Welcome mate :)
 

Perfect answer from Mr. Stuart and thanks.

I am adding few points about its advantages.

1. If you plan to work multiple chart / pair, just change the magic number, it will work individually for the single chart / pair only.

2. If you plan, EA should work in EUR USD at a time 2 chart, one is  starting with buy and another one starting with sell, you have to change magic number, EA will work both way for single pair i.e. EURUSD.

3. If you disconnect from mt4 and reconnect, EA will not start from the starting, EA will read the previous journal (Help with magic number),  then will start perform from the last activities.

4. You can trade manually also in the same chart, EA will not affected if you use magic numbers.

Thanks. 

Reason: