How can we using code DETERMINE How many EA is running and attached the chart? - page 2

 
Nguyen Nga:
code an EA to save template file of each chart, then make EA to read template file and get EA name.
how can I know  the EAs is running or trade not allowed?
 
Marco vd Heijden:

Dear hongbin fei,

Please try and attach two EA's to a single chart.

Let me know if you succeed.

excellent advice!
 
hongbin fei:
how can I know  the EAs is running or trade not allowed?
<expert>
name=Simple_EA
flags=343
read template file, if it have EA name, EA running. value of flags = 343 : allow live trading and allow both long, short.
 
David Raine:
excellent advice!
Well technically it is possible to have an EA work with other charts so in that sense the all other charts can be directed from other EA's but in those cases the EA itself isn't attached (initialized) onto the chart so if the chart is running another EA that is initialized on the chart itself it will still not count as two Ea's on one chart.
 
hongbin fei:
How can we using code DETERMINE How many EA is running and attached  the chart?

Maybe you can use the example of code to find out how many EA the attached on the chart.


  string eaname="YOUREANAME";
  //--
  long currChart,prevChart=ChartFirst();
  int c=0,ex=0,cht=36; // not more than 36 open charts
  while(c<cht)
    { 
      currChart=ChartNext(prevChart); // Get the new chart ID by using the previous chart ID
      if(currChart<0) break;          // Have reached the end of the chart list
      prevChart=currChart;            // let's save the current chart ID for the ChartNext()
      if(WindowExpertName()==eaname) {ex++;} // sum EA attachted on chart
      c++; // Do not forget to increase the counter 
    }
  //--
  Print("-----Total EA ",eaname," attached on the charts are ",string(ex));
 
Nguyen Nga:
read template file, if it have EA name, EA running. value of flags = 343 : allow live trading and allow both long, short.
thanks
 
Nguyen Nga:
read template file, if it have EA name, EA running. value of flags = 343 : allow live trading and allow both long, short.

I saved the chart to template, but error while open: 

2016.07.12 00:39:34.515 Notify GBPUSD,M30: Failed to open C:\Program Files\MetaTrader 4 IC Markets\templates\MVE131127257216093752.tpl file, Error code = 5002

 

Thanks for help. 

 
Mt4 can not open it. 
 

better use DLL to copy the file to Experts\Files

#import "kernel32.dll"
bool CopyFileW(string lpExistingFileName, string lpNewFileName, bool failIfExists); 
#import
Reason: