How to calculate if we are under 4 or 5 digit broker

 

Is there a better ‘formula’ in MQL4 to know if the EA is executing on a 4 digit broker or in a 5 digit broker?

 

int digits = (int) MarketInfo("EURUSD", MODE_DIGITS);

//digits is expected to be 5 in 5 digits brokers, and 4 in 4 digits brokers

 
  1. Remember it's 4/5 except on JPY pairs (2/3)
               What is a TICK? - MQL4 and MetaTrader 4 - MQL4 programming forum

  2. There is also the predefined _Digits
 
whroeder1:
  1. Remember it's 4/5 except on JPY pairs (2/3)
               What is a TICK? - MQL4 and MetaTrader 4 - MQL4 programming forum

  2. There is also the predefined _Digits

Thanks for the response. (I was asking/looking for some kind of BrokerInfo or AccountInfo function).

To avoid headaches in calculations I'm thinking about implementing some control like this in all my programs:

int onInit() {
        int digits = (int) MarketInfo("EURUSD", MODE_DIGITS);
        if (digits == 4) {
                Alert("Program not prepared for 2/4 digit brokers. Try to migrate to a 3/5 broker!");
                return -1;
        }

        //... normal program execution
}

 
You should calibrate your expert per market, not per broker. 5 digit brokers can have 2 digit markets as well, Gold being the most common case.