MQL4 WindowExpertName() does not solve my problem

 

I'm writing a code to detect a chart that is running a specified EA. I know the EA name. In MQL5, I use ChartGetString(chart_id, CHART_EXPERT_NAME) to detect if a chart is running the specified EA. MQL4 does not have ChartGetString() but has WindowExpertName(). However, WindowExpertName() returns the caller's name, not the chart I'm detecting.

Anyone could help?

Thanks

 
Longsen Chen: MQL4 does not have ChartGetString() 

Yes it does (ChartGetString - Chart Operations - MQL4 Reference) just not useful to you.

What are you going to do differently depending on the result?


If you have the EA's code, have it create a Global Variable OnInit and remove it OnDeinit. Someting like «EA_NAME»_ «CHARTID».

You could also try creating a hard link between «DataFolder»/../templates/X.tpl and «DataFolder»/Files/X.tpl, call ChartSaveTemplate and then read the template looking for

<expert>
name=«EA_NAME»
 

Thank you for your reply.

Unfortunately I don't have EA code. So Global Variable wouldn't work.

I may forcily apply template to some chart. The template may contain target EA. My code knows each chart who runs the target EA. In this way I don't need to detect but know the charts in advance.

Thank you very much

 
Assuming you know which chart the EA will be running on, you could also write a simple indicator, drop it in the chart with the EA, then have the indicator set a global variable with the chart ID.
 

I use ChartFirst and ChartNext to iterate all charts and detect each chart if it has the specific EA. The link below helps.

https://www.mql5.com/en/forum/225408/page2

How can I detect by my Indicator code if an Expert is placed on the chart?
How can I detect by my Indicator code if an Expert is placed on the chart?
  • 2018.01.23
  • www.mql5.com
I have an Indicator that displays some information panes on the Chart window and one of them is at the right top side of the chart...
Reason: