Download MetaTrader 5
To add comments, please log in or register
Do you need OpenCL? MQL5 can provide it!
Dave90210
1405
Dave90210 2015.04.01 22:14 
I have an EA a programmer said the magic number isn't being recognized. How do I see if the magic number is being recognized by mt4 is there a way to test and validate this without being programmer? 
Drazen Penic
2498
Drazen Penic 2015.04.01 22:39  

This is strange question.

Magic number is not mandatory in the order, but if there is a magic in the order, you can read it from MQL.

Magic number can be written to the order only at the moment when the order is opened. It can't be changed after that.  

 

Attached is a script that will list order tickets and corresponding magic numbers. List will be visible at the Experts tab. 

Copy attached file to the scripts folder. 

Files:
Dave90210
1405
Dave90210 2015.04.01 23:00  
drazen64:

This is strange question.

Magic number is not mandatory in the order, but if there is a magic in the order, you can read it from MQL.

Magic number can be written to the order only at the moment when the order is opened. It can't be changed after that.  

 

Attached is a script that will list order tickets and corresponding magic numbers. List will be visible at the Experts tab. 

Copy attached file to the scripts folder. 

Thank you so much I'll have a look at the script. Do you think the magic number issue might be causing multiple EA's opening at the same time even though they have different logic? In those EA's I have different magic numbers for each 
Drazen Penic
2498
Drazen Penic 2015.04.01 23:27  

Magic number is just some random value you can attach to you order. It is usually used as means of order identification. For example - you can read that number from the order and then decide if that order should be included in some decision.

You must ask your developer what exactly he means  with "magic number isn't being recognized". If order has magic number, you can read it. If order does not have magic number - you can't read it. 

Without code it is impossible to tell what is happening. 

Stuart Browne
5720
Stuart Browne 2015.04.02 00:18  
Dave90210:
Thank you so much I'll have a look at the script. Do you think the magic number issue might be causing multiple EA's opening at the same time even though they have different logic? In those EA's I have different magic numbers for each 
G'day Dave

Were the EA's all created by the same coder? If so, he may have accidentally hard coded the same magic into every EA rather than using the input variable. As drazen said above, without seeing the code the best we can do is guess ;)

Cheers
Dave90210
1405
Dave90210 2015.04.02 00:31  
Filter:
G'day Dave

Were the EA's all created by the same coder? If so, he may have accidentally hard coded the same magic into every EA rather than using the input variable. As drazen said above, without seeing the code the best we can do is guess ;)

Cheers
I sent you a PM with the code. Originally only one guy worked on it and later someone came in to make some changes and thats when he said he say an error with the magic number 
Drazen Penic
2498
Drazen Penic 2015.04.02 01:05  

After a quick look, it seems that there shouldn't be magic number problems in this EA.

Only thing I discovered is that EA does not check magic number when it is closing order.

So, if you have same type orders on the same currency pair, this EA will close all of them, no matter which magic number they have.

This means that EA can close orders that it did not open. 

 

Detailed test requires time and you should provide detailed description of problems - what is happening and what you expected to happen. 

Stuart Browne
5720
Stuart Browne 2015.04.02 01:17  
I can confirm the same as drazen, it will close all orders on that symbol. Sent you a PM too :)
John Baker
645
John Baker 2015.04.02 03:48  
Thank you all. I have had the same question about magic numbers.  This helps!
/
To add comments, please log in or register