What is and how to set the magic number at EA's ?

 
I am testing some EA's but I do not know what is and how to set the "magic number".

What determine wich magic number to use?

Do I set the same magic number at one currency pair at different timeframes? or not?

Do I set the same magic number at different currencies? What happens if a set the same one?

Can I use the magic number to make the EA manage the trades I open manually?



I want to understand what is magic number.

Thanks for any information.

Eduardo
 

Magic number is intended to be used for trade identification. Implementation varies.

It is set when the trade is opened by an EA with the OrderSend() command.

Example usage:

You have two EA trading EURUSD

To permit each EA to recognize trades that "belong to it" set a different magic number (ID) with each EA.

 
Thank you.

But if I have only one EA, two EURUSD charts at different time frames? Do I have to change the magic number? What number to define? Anyone?

Each window, independently of the currency or time frame, need your own magic number to MetaTrader identify in what trade act?

I am not talking about code. I am talking about the magic number to complete when I drag the EA from navigator window to chart window.


Was I clear? sorry the poor english.


thanks
 
I believe Phy can solve your problem better, but I was using Period() as a magic number in case like that.
 

"But if I have only one EA, two EURUSD charts at different time frames? Do I have to change the magic number? What number to define? Anyone?"

Try "1" and "2"

 
Then it is simple?

I just have to determinate a number I choose each chart window? Ok!!

Is there a specific magic number If I want the EA manage the trade opened manually?

Thanks
 

Is there a specific magic number If I want the EA manage the trade opened manually?

Probably "0"


You could use the Comment to identy manual trades, and add a test for specific comment in the EA.

 

Hello,

I have five charts on one platform for five diferent currencies (one chart per currency).

I apply same EA for all the five charts (same EA for all the five currecies).

Do I need to change the magic number of the EA for each chart (each currency)?

Thanks

-Chandra

 
phy wrote >>

Is there a specific magic number If I want the EA manage the trade opened manually?

Probably "0"


You could use the Comment to identy manual trades, and add a test for specific comment in the EA.

Hello Phy,

I have five charts on one platform for five diferent currencies (one chart per currency).

I apply same EA for all the five charts (same EA for all the five currencies).

Do I need to change the magic number of the EA for each chart (each currency)?

Thanks

-Chandra

 
Chandra_Sekhar wrote >>

Hello Phy,

I have five charts on one platform for five diferent currencies (one chart per currency).

I apply same EA for all the five charts (same EA for all the five currencies).

Do I need to change the magic number of the EA for each chart (each currency)?

Thanks

-Chandra

Hi Chandra,

Short answer is no. Correct answer is - it depends. Your EA must be smart enough to determine which currecy it is operating on if there are any order modifications or deletions done. Magic number is one way to do that, although a good EA will use other methods as well such as currency pair checking.

You will need to determine whether or not your code is robust enough to operate without a magic number change - or whether or not it even uses the magic number

- Tovan

Reason: