Download MetaTrader 5
To add comments, please log in or register
Speed up MQL5 Cloud Network. Install Strategy Tester Agent!
lacp.forex
147
lacp.forex 2014.05.20 04:30 
I am building a EA to manage an account where two or more EA´s are trading. I need to know for each EA the Magic Number and Chart ID where the EA is running, and I need to known it from the EA that is managing the account.

The functions ChartFirst and ChartNext allow to know the Chart ID of all open Charts. The ChartClose function allows to close a specific Chart and the corresponding EA.

The OrderMagicNumber function allows to discover which EA is not producing the expected result. But how to relate the MagicNumber with the ChartID in order to close the correct Chart and corresponding EA that is not running properly ?

Thanks.
whroeder1
13602
whroeder1 2014.05.20 20:50  
lacp.forex:. But how to relate the MagicNumber with the ChartID

There isn't any. An EA on any chart can use any magic number it likes.

  1. Change EA to use its ChartID as its magic number
  2. Change EA to create a terminal variable that maps ChartID to magic number.
    name=Symbol()
         + EnumToString( ENUM_TIMEFRAMES(_Period) )
         + " cid=" + IntegerToString(ChartID);
    GlobalVariableSet(name, MagicNumer);

/
To add comments, please log in or register