EA showing data for the symbol it is attached to instead of showing data for the symbol that is in focus

 

Hi,

I have read a lot of information on the website but I couldn't really find an answer to my question.

I have a EA which opens a user interface once it is attached to a given chart(say GBPJPY). What I want to achieve is basically when I open a different chart GBPUSD I want the EA to detect this change and display information about the current symbol that is in focus.

How can I achieve this is MQL5?

Thanks in advance!

 
Code it to process/display only the current chart. Then when you open a different chart it processes that.
I recommend: Do not trade multiple currencies in one EA.
  1. You can't use any {MT4: predefined variables, MT5: predefined variables,}
  2. Must poll (not OnTick, unless you use specific indicators)
              The Implementation of a Multi-currency Mode in MetaTrader 5 - MQL5 Articles
  3. and usually other problems, e.g. A problem with iBarShift - MQL4 programming forum - Page 2
  4. You must handle History {MT4:4066/4073 errors: Download history in MQL4 EA - MQL4 programming forum, MT5: Timeseries and Indicators Access /  Data Access - Reference on algorithmic/automated trading language for MetaTrader 5.}
  5. Code it to trade the chart pair only. Look at the others if you must. Don't assume that Time[i] == iTime(otherPair, TF, i) always use iBarShift.
  6. Then put it on other charts to trade the other pairs. Done.
 
William Roeder:
Code it to process/display only the current chart. Then when you open a different chart it processes that.

Thank you for your reply William! I had a look at the article for multi currency mode and I can't see how I can get to know which the new open chart is so I can pass that to the EA.

Can you be more specific please?

 
roniko1994: I can't see how I can get to know which the new open chart is so I can pass that to the EA. Can you be more specific please?

What part of "process/display only the current chart" was unclear? You don't need to know. Put it on one chart and save the default template. When you open a second chart it will be on that chart. No coding required.

 
William Roeder:

What part of "process/display only the current chart" was unclear? You don't need to know. Put it on one chart and save the default template. When you open a second chart it will be on that chart. No coding required.

I use ChartID() and Symbol() in my EA but no matter which chart I open or which tab I switch to it still refers to the symbol that the EA is attached to.

So what I want to handle is not only detect a new symbol when a new chart is open but also when you click a different tab. Attached is a screenshot. If I attach the EA to GBPUSD and then click on the tab EURNZD I would like the EA to pick up this change and show the relevant information for EURNZD. Also if EURNZD is not available in the tabs below I would like to open it from the market watch and I would like to get the same result.

I hope that this makes sense

Files:
example.PNG  54 kb
Reason: