The same statement but different result in EA compared with Script or Indicator: AccountInfoString(ACCOUNT_CURRENCY);

 

Anyone an Idea why I get different result on a EUR accouct about the value of the account-currency?

I need the value of the account in an EA.



Expert advisor give's as result: USD (???)

//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick()
  {
//---   
   Comment ("Account-info AccountInfoString(ACCOUNT_CURRENCY): ", AccountInfoString(ACCOUNT_CURRENCY));
  }
//+------------------------------------------------------------------+



The same statement in a Script gives the right value as a result; EUR

//+------------------------------------------------------------------+
//| Script program start function                                    |
//+------------------------------------------------------------------+
void OnStart()
  {
//---
   Comment ("Account-info AccountInfoString(ACCOUNT_CURRENCY): ", AccountInfoString(ACCOUNT_CURRENCY));
 return;
  }
//+------------------------------------------------------------------+


The same statement in an Indicator gives the right value too : EUR

//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int  OnCalculate(const int rates_total,
                const int prev_calculated,
                const datetime& time[],
                const double& open[],
                const double& high[],
                const double& low[],
                const double& close[],
                const long& tick_volume[],
                const long& volume[],
                const int& spread[])
               
{
  Comment ("Account-info AccountInfoString(ACCOUNT_CURRENCY): ", AccountInfoString(ACCOUNT_CURRENCY));
 return(1);
 }


What is wrong with this statement in the EA?? Why gives it USD as a result?

Thanks for answering!

 
I checked in build 2650 - no error. The EA determines the account currency correctly: both USD and EUR and RLS.
 

Dear Vladimir,

Thanks for your answer.

My follow up question: did the statement give the right value in all three (3) possibilities: in an EA, in an Indicator and in a Script?

Further: the core question is what could cause the wrong value in an Expert Advisor (in this case USD)?


By the way,...

1. As you can see; You can use the above declared code.
2. I have the problem with two MT5 accounts at two different brokers (Blueberry and IC-Markets).
 
Marine :

Dear Vladimir,

Thanks for your answer.

My follow up question: did the statement give the right value in all three (3) possibilities: in an EA, in an Indicator and in a Script?

Further: the core question is what could cause the wrong value in an Expert Advisor (in this case USD)?


By the way,...

1. As you can see; You can use the above declared code.
2. I have the problem with two MT5 accounts at two different brokers (Blueberry and IC-Markets).

I have a guess: switch the terminal language to English. And check again.

 

Hi Vladimir,

Weird proposal ;-). But like Naänman in the Bible (2 kings 5: 1-27). First I didn’t want to listen, then I did what you said and changed the language...,

...no result,... BUT, BUT,..

..., BUT,.. this leaded me to something else a bit "similar",...

..., with your suggestion I found the solution (and the cause) why this the statement  “AccountInfoString(ACCOUNT_CURRENCY)” can deliver another value for an Expert Advisor.

Although the account is in a certain currency (obtained from the Brooker), and in my case the EUR, you can - only for an EXPERT and for testing purposes- change the "Deposit currency" (see below screenshots account and overlayed tester visualization).

And that is the reason why the indicator or script always shall - of course - display the real account setting:


Screenshot EA-settings


Thanks Vladimir for your suggestion!

Marine