Broker digit conversion function

 

Hello all, my question is if this function is stated correctly?

int Pips()
{          
      double Pips = Point;
      
       if(Digitos == Cinco)
         {
           Pips = Point*10;
            return(10);
          }
        else if(Digitos == Cuatro)
         {
            Pips = Point;
             return(1);
          }
        return(-1);    
} 

It's made to be able to adapt the SL, TP and Slippage values according to the amount of digits on the broker and it supports 4 or 5 digits broker.

My doubt is on the return(-1); part as I have to return something on the last path to avoid getting "not all control paths returns a value" error. It's technically imposible to get that return but I want to make sure by having another opinion:)

Thanks guys!

 
FernandoBorea:

Hello all, my question is if this function is stated correctly?

It's made to be able to adapt the SL, TP and Slippage values according to the amount of digits on the broker and it supports 4 or 5 digits broker.

My doubt is on the return(-1); part as I have to return something on the last path to avoid getting "not all control paths returns a value" error. It's technically imposible to get that return but I want to make sure by having another opinion:)

Thanks guys!

double Pips(string pSymbol = NULL)
{
   double iPoint = SymbolInfoDouble(pSymbol == NULL ? Symbol() : pSymbol, SYMBOL_POINT);
   return Digits == 3 || Digits == 5 ? (iPoint * 10) : iPoint;
}
 
FernandoBorea:

Hello all, my question is if this function is stated correctly?

It's made to be able to adapt the SL, TP and Slippage values according to the amount of digits on the broker and it supports 4 or 5 digits broker.

My doubt is on the return(-1); part as I have to return something on the last path to avoid getting "not all control paths returns a value" error. It's technically imposible to get that return but I want to make sure by having another opinion:)

Thanks guys!

I am tired to move your topic to the right section.

mql4 question in mql4 section, is that hard to understand ?

 

Hi whroeder1

you are right,I was wrong.....

double Pips(string pSymbol = NULL)
{
   double iPoint = SymbolInfoDouble(pSymbol == NULL ? Symbol() : pSymbol, SYMBOL_POINT);
   int iDigits = SymbolInfoInteger(pSymbol == NULL ? Symbol() : pSymbol, SYMBOL_DIGITS);
   return iDigits == 3 || iDigits == 5 ? (iPoint * 10) : iPoint;
}

in this mode is possible to use function for other symbol

 
I'd simplify thus:
double Pips(void){ return Pips(_Symbol); }
double Pips(string pSymbol){
   double iPoint = SymbolInfoDouble(pSymbol, SYMBOL_POINT);
   if(SymbolInfoInteger(pSymbol, SYMBOL_DIGITS) % 2 != 0) iPoint *= 10.;
   return iPoint;
}
or
double Pips(string pSymbol = NULL){
   if(pSymbol == NULL) pSymbol = _Symbol;
   double iPoint = SymbolInfoDouble(pSymbol, SYMBOL_POINT);
   if(SymbolInfoInteger(pSymbol, SYMBOL_DIGITS) % 2 != 0) iPoint *= 10.;
   return iPoint;
}