Home>

https://minagachi.com/price-to-pips
I tried to set the price to pips with reference to this site, but I copied and copied the code as it was, but I got an error.
I want to eliminate the error.

'PriceToPips'-function declarations are allowed on global, namespace or class scope only pips.mq4 40 8
Applicable source code
//+----------------------------------------------- -------------------+
//| Function to convert price to pips
//+----------------------------------------------- -------------------+
double PriceToPips(double price)
{
   double pips = 0;
   // Get the number of decimal places of the current currency pair
   int digits = (int)MarketInfo(Symbol(), MODE_DIGITS);
   // In case of 3 digit/5 digit FX broker
   if(digits == 3 || digits == 5){
     pips = price * MathPow(10, digits)/10;
   }
   // For 2-digit and 4-digit FX brokers
   if(digits == 2 || digits == 4){
     pips = price * MathPow(10, digits);
   }
   // Round the decimal point to one digit (change the number of digits depending on the purpose)
   pips = NormalizeDouble(pips, 1);
   return(pips);
}
What I tried

I looked up the error code, but I do not understand it well, I tried translating it
"Function declarations are only allowed in global, namespace, or class scope."
It came out.
However, I'm just starting the program and I don't understand what it means.

Supplemental information (FW/tool ​​version, etc.)

Please provide more detailed information here.