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

 

Hi. I can't get rid of these errors at compilation stage. It seems to me that I'm using a correct syntax but if there is an error then I'm definitely doing something wrong. Can you show me where the problem is?


Errors: 


'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&)

 

'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&)


// Function to place a buy order using MqlTick for Ask price with immediate trailing stop activation
bool PlaceBuyOrder() {
    MqlTick tick;
    SymbolInfoTick(_Symbol, tick); // Get the latest tick data
    
    double price = tick.ask; // Use Ask price from the terminal
    double sl = NormalizePrice(price - StopLossPoints * _Point); // Normalize Stop Loss
    double tp = NormalizePrice(price + TakeProfitPoints * _Point); // Normalize Take Profit
    double lotSize = NormalizeLots(LotSize); // Normalize lot size

    // Validate lot size
    if (lotSize == 0) {
        Print("Error: Lot size too small.");
        return false;
    }

    // Get the minimum distance for Stop Loss and Take Profit (using the first overload)
    double minDistance = SymbolInfoDouble(_Symbol, SYMBOL_TRADE_STOPS_LEVEL) * _Point; // Directly return and convert to points

    // Validate stop loss and take profit distance
    if ((sl > (price - minDistance)) || (tp < (price + minDistance))) {
        Print("Error: Invalid SL or TP distance.");
        return false;
    }

    MqlTradeRequest request;
    MqlTradeResult result;

    request.action = TRADE_ACTION_DEAL;
    request.symbol = _Symbol;
    request.volume = lotSize;
    request.price = price;
    request.sl = sl;
    request.tp = tp;
    request.deviation = Slippage;
    request.type = ORDER_TYPE_BUY;
    request.type_filling = ORDER_FILLING_FOK; // Fill or Kill
    request.type_time = ORDER_TIME_GTC;       // Good Till Canceled

    if (!OrderSend(request, result)) {
        Print("Buy order failed: ", result.retcode);
        return false;
    }

    // Immediately start trailing Stop Loss after order is placed
    double newSL = NormalizePrice(tick.ask - StopLossPoints * _Point);
    request.action = TRADE_ACTION_SLTP;
    request.sl = newSL;
    if (!OrderSend(request, result)) {
        Print("Error modifying buy order for immediate trailing stop: ", result.retcode);
    }

    return true;
}

// Function to place a sell order using MqlTick for Bid price with immediate trailing stop activation
bool PlaceSellOrder() {
    MqlTick tick;
    SymbolInfoTick(_Symbol, tick); // Get the latest tick data

    double price = tick.bid; // Use Bid price from the terminal
    double sl = NormalizePrice(price + StopLossPoints * _Point); // Normalize Stop Loss
    double tp = NormalizePrice(price - TakeProfitPoints * _Point); // Normalize Take Profit
    double lotSize = NormalizeLots(LotSize); // Normalize lot size

    // Validate lot size
    if (lotSize == 0) {
        Print("Error: Lot size too small.");
        return false;
    }

    // Get the minimum distance for Stop Loss and Take Profit (using the first overload)
    double minDistance = SymbolInfoDouble(_Symbol, SYMBOL_TRADE_STOPS_LEVEL) * _Point; // Directly return and convert to points

    // Validate stop loss and take profit distance
    if ((sl < (price + minDistance)) || (tp > (price - minDistance))) {
        Print("Error: Invalid SL or TP distance.");
        return false;
    }

    MqlTradeRequest request;
    MqlTradeResult result;

    request.action = TRADE_ACTION_DEAL;
    request.symbol = _Symbol;
    request.volume = lotSize;
    request.price = price;
    request.sl = sl;
    request.tp = tp;
    request.deviation = Slippage;
    request.type = ORDER_TYPE_SELL;
    request.type_filling = ORDER_FILLING_FOK; // Fill or Kill
    request.type_time = ORDER_TIME_GTC;       // Good Till Canceled

    if (!OrderSend(request, result)) {
        Print("Sell order failed: ", result.retcode);
        return false;
    }

    // Immediately start trailing Stop Loss after order is placed
    double newSL = NormalizePrice(tick.bid + StopLossPoints * _Point);
    request.action = TRADE_ACTION_SLTP;
    request.sl = newSL;
    if (!OrderSend(request, result)) {
        Print("Error modifying sell order for immediate trailing stop: ", result.retcode);
    }

    return true;
}
 

It should be:

double stopsLevel = SymbolInfoInteger(_Symbol, SYMBOL_TRADE_STOPS_LEVEL) * _Point;


Please look in the provided documentation

https://www.mql5.com/en/docs/constants/environment_state/marketinfoconstants

Documentation on MQL5: Constants, Enumerations and Structures / Environment State / Symbol Properties
Documentation on MQL5: Constants, Enumerations and Structures / Environment State / Symbol Properties
  • www.mql5.com
To obtain the current market information there are several functions: SymbolInfoInteger() , SymbolInfoDouble() and SymbolInfoString() . The first...