how to find the Chart Items, including its existing Expert Advisor.

 

It is necessary to avoid a duplicate working of my Expert Advisor in paralel Charts.

For ex, if it is already running in EURUSD chart, then if a user loads it into GBPUSD, it should not work but exit.

It is because, my EA is not related to only one instrument or one chart, it works with several of them internally.

Any idea?

I can refer to Chat names with such code:

int RunEE () {long curr_chart=ChartFirst();int i=0;while(!IsStopped() && i < CHARTS_MAX) //Print ("Robot=",WindowExpertName())

{PrintFormat("Chart[%d] ID: %I64d,  symbol: %s, Robot: %s", i, curr_chart, ChartSymbol(curr_chart),WindowExpertName());i++;curr_chart=ChartNext(curr_chart); if(curr_chart<0) break;}

return 0;}


But I cannot find the EA-s running on each chart...., instead of Robot name in each chart it give the EA on the current (active) chart, where I run the advisor itself....


Look forward to your comments.

Thanks in advance.

 
There might be a way to achieve this.

However, why do you want the EA to avoid trading on specific currency pairs?
 

Dear Farzad, 


Thanks a lot for your kind reply. It is not easily organised in mql4, I don know why.... It should be an easy task, but I cannot see the the way to do this for a time being.

Why do i need need the EA to do trading with only one pair, because, I do analysing among different symbols and after judging properlly, I select the right ones for trading... So this is kind of multi-currency EA.

I actually need 1 copy at the same time (let say EURUSD). If the user uploads copies into other charts (USDCAD, XAUUSD, etc), they should not be working, as several copies can create problem to each-other...

I need to check if the robot is already running... if not then we work, if it is already working on the other chart, then we simply quit...

 

Thanks Farzad and many thanks to Lorentzos, it looks his function:

ChartSetSymbolPeriod

can help. I will give a try to this one as it forces the chart to reinitialize its EA component, maybe it can work, I will inform about the results.