Magic Number X Chart ID in MQL4

 
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.
 
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);

Reason: