How to discover the two currencies on a specific chart - page 2

 
ernest02:

I realise that a Symbol that has a prefix will give a wrong result with the code I have written, but I do not want a general EA just one that works with my broker which has no prefixes to their symbols.

Also, I do not want to read some HTML to get a country name or Symbol since I am writing an EA that must detect from a custom indicator when a certain currency strength exceeds/crosses that of the other.

That is why I was hoping to get some guidance on code that I can use to loop through an array to select the two currencies that is applicable to the particular chart and then use this info to create the general double variables that I can populate with the strength of the currency at shift 1 and shift 0.



Obviously, it depends on how the custom indicator operates. Does it just update without storing the data or does it store each bars data in a buffer?

If it just updates and displays the value on the chart as a label, as long as the label has the currency in its name, you may be able to get the value from it.

Maybe you could use something like this

// as an example, the label name is "strengthEUR"
    double FirstCurrStrength;
    static double FirstCurrStrengthlastbar;
    static datetime BarTime;
    
    string CurrPair = Symbol();
    string FirstCurr = StringSubstr(CurrPair,0,3);
    string SecondCurr = StringSubstr(CurrPair,3,3);
    FirstCurrStrength = StrToDouble (ObjectDescription("strength"+FirstCurr));
    
    if(Time[0]!= BarTime)
       {
       FirstCurrStrengthlastbar = FirstCurrStrength;
       BarTime = Time[0];
       }
Reason: