'SymbolInfoDouble' - no one of the overloads can be applied to the function call

 
   int minStopLevel = SymbolInfoInteger(Symbol(), SYMBOL_TRADE_STOPS_LEVEL);
   if (minStopLevel == -1)
     {
      Print("Error retrieving minimum stop level");
      return;
     }
   double minStopDistance = minStopLevel * _Point;

   double spread;
   if (!SymbolInfoDouble(Symbol(), SYMBOL_SPREAD, spread))
     {
      Print("Error retrieving spread");
      return;
     }
   spread *= _Point; 

How can i fix this error? Its so hard to fix im new to coding!

 
manosgk:

How can i fix this error? Its so hard to fix im new to coding!

Try this
long minStopLevel = SymbolInfoInteger(Symbol(), SYMBOL_TRADE_STOPS_LEVEL);
if (minStopLevel == -1)
{
    Print("Error retrieving minimum stop level");
    return;
}
double minStopDistance = minStopLevel * _Point;

double spread;
if (!SymbolInfoDouble(Symbol(), SYMBOL_SPREAD, spread))
{
    Print("Error retrieving spread");
    return;
}
spread *= _Point;
 
sNicola Capatti #:
Try this
long minStopLevel = SymbolInfoInteger(Symbol(), SYMBOL_TRADE_STOPS_LEVEL);
if (minStopLevel == -1)
{
    Print("Error retrieving minimum stop level");
    return;
}
double minStopDistance = minStopLevel * _Point;

double spread;
if (!SymbolInfoDouble(Symbol(), SYMBOL_SPREAD, spread))
{
    Print("Error retrieving spread");
    return;
}
spread *= _Point;
i still get the same error
 
manosgk #:
i still get the same error

what exactly does it tell you as an error?

 
Nicola Capatti #:

what exactly does it tell you as an error?

  long minStopLevel = SymbolInfoInteger(Symbol(), SYMBOL_TRADE_STOPS_LEVEL);
   if (minStopLevel == -1)
   {
      Print("Error retrieving minimum stop level");
      return;
   }
   double minStopDistance = minStopLevel * _Point;

   double spread;
   if (!SymbolInfoDouble(Symbol(), SYMBOL_SPREAD, spread))
   {
      Print("Error retrieving spread");
      return;
   }
   spread *= _Point;

'SymbolInfoDouble' - no one of the overloads can be applied to the function call

could be one of 2 function(s)

built-in: double SymbolInfoDouble(const string,ENUM_SYMBOL_INFO_DOUBLE)

built-in: bool SymbolInfoDouble(const string,ENUM_SYMBOL_INFO_DOUBLE,double&)





 
manosgk #:

'SymbolInfoDouble' - no one of the overloads can be applied to the function call

could be one of 2 function(s)

built-in: double SymbolInfoDouble(const string,ENUM_SYMBOL_INFO_DOUBLE)

built-in: bool SymbolInfoDouble(const string,ENUM_SYMBOL_INFO_DOUBLE,double&)





The error message you are receiving is because you are trying to use the SymbolInfoDouble function in an incorrect way. The function has two overloads:

  1. Overload that returns a double directly:

double value = SymbolInfoDouble(Symbol(), ENUM_SYMBOL_INFO_DOUBLE);

      2. Overload that returns a boolean ( bool ) and requires a parameter passed by reference ( double& ) to store the result:

bool success = SymbolInfoDouble(Symbol(), ENUM_SYMBOL_INFO_DOUBLE, value);


In your case, you are trying to use the second overload, but you are not doing it correctly. You should pass a parameter by reference, not by value.

Here is how you can fix the code:

double spread;
if (!SymbolInfoDouble(Symbol(), SYMBOL_SPREAD, spread))
{
    Print("Error retrieving spread");
    return;
}
spread *= _Point;


With this modification, the spread value will be correctly passed by reference to the SymbolInfoDouble function, and the function will return true if it was able to retrieve the value, or false otherwise.

Also, make sure you have declared spread as double before calling the function. This code should work without any issues.