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

 
//+------------------------------------------------------------------+
//|                                             Naz Sell EAs (1).mq5 |
//|                        Copyright 2023, MetaQuotes Software Corp. |
//|                                             https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2023, MetaQuotes Software Corp."
#property link      "https://www.mql5.com"
#property version   "1.00"
#property strict

// Define the input parameters
input double LotSize = 0.01;
input double TargetProfit = 450;
input double StopLoss = 300;
input int MaxLots = 10;
input int MinLots = 2;
input int TrailingStop = 222;
input int HighPricePips = 10;
input int RSI_Period = 7;
input int Stoch_K_Period = 3;
input int Stoch_D_Period = 3;
input int RSI_Threshold = 90;
input int Stoch_Threshold = 90;
input int Slippage = 13; // Maximum allowed slippage
input int MagicNumber = 12345; // Magic number for trades

double availableBalance;
double maxLotSize;
double tradeLotSize;
int openOrderCount = 0;

//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void OnTick()
{
    double RSI_Value = iRSI(Symbol(), 0, RSI_Period, PRICE_CLOSE);
    double Stoch_K_Value = iStochastic(Symbol(), 0, Stoch_K_Period, Stoch_D_Period, MODE_SMA, 0, 0);

    if (RSI_Value <= RSI_Threshold && Stoch_K_Value <= Stoch_Threshold)
    {
        int newOrderCount = MinLots - openOrderCount;
        if (newOrderCount > 0)
        {
            for (int j = 0; j < newOrderCount; j++)
            {
                double spread = SymbolInfoDouble(Symbol(), SYMBOL_SPREAD);
                double askPrice = SymbolInfoDouble(Symbol(), SYMBOL_ASK);
                double point = SymbolInfoDouble(Symbol(), SYMBOL_POINT);

                if (spread >= HighPricePips * point)
                {
                    MqlTradeRequest request;
                    MqlTradeResult result;
                    ZeroMemory(request);
                    ZeroMemory(result);

                    request.action = TRADE_ACTION_DEAL;
                    request.type = ORDER_TYPE_SELL;
                    request.volume = tradeLotSize;
                    request.price = askPrice;
                    request.deviation = Slippage;
                    request.magic = MagicNumber;
                    string comment = "Order Sell v1";

                    uchar commentCharArr[];
                    StringToCharArray(comment, commentCharArr);

                    request.comment = commentCharArr;

                    bool res = OrderSend(request, result);
                }
            }
        }
    }

    openOrderCount = OrdersTotal();
}

//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void OnStart()
{
    availableBalance = AccountInfoDouble(ACCOUNT_BALANCE);
    double point = SymbolInfoDouble(Symbol(), SYMBOL_POINT);
    maxLotSize = availableBalance * 0.5 / (StopLoss * point);
    tradeLotSize = NormalizeDouble(LotSize, 2);
}

Hi 

How can solve those errors: 

First Error:


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

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

Secon Error:

'commentCharArr' - invalid array access

implicit conversion from 'number' to 'string'

Improperly formatted code removed by moderator. Please EDIT your post and use the CODE button (Alt-S) when inserting code.

Code button in editor

Hover your mouse over your post and select "edit" ... 

 
Nazar Jawas:

Hi 

How can solve those errors: 

First Error:


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

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

Secon Error:


'commentCharArr' - invalid array access

implicit conversion from 'number' to 'string'

Please post your code properly, use the code button.

Second issue: you are applying an uchar array to a string variable.

After posting correctly, get the answer to your first question.
 
Dominik Christian Egert #:
Please post your code properly, use the code button.

Second issue: you are applying an uchar array to a string variable.

After posting correctly, get the answer to your first question.

Hi brothers,

I update and posted the code.


Thanks for cooperation.

 
Nazar Jawas #:

Hi brothers,

I update and posted the code.


Thanks for cooperation.


Your first error:

long spread = SymbolInfoInteger(Symbol(), SYMBOL_SPREAD)


Your second error, Change this:

request.comment = comment;
 
what is the solution? How to fix those errors?
 
Nazar Jawas #:
what is the solution? How to fix those errors?
I posted the solutions. Please read and compare with your code.
 
Nazar Jawas #:
what is the solution? How to fix those errors?
Are you on MT4??

Your file shows .mq5

You are using these wrong:
They return a handle and need to go into OnInit.
Then you use CopyBuffer with the handle to get the data from the indicators. - Wondering, you should receive warnings from your compiler....

You need to do some search on the forum about this wrong code (for MQL5):

    double RSI_Value = iRSI(Symbol(), 0, RSI_Period, PRICE_CLOSE);
    double Stoch_K_Value = iStochastic(Symbol(), 0, Stoch_K_Period, Stoch_D_Period, MODE_SMA, 0, 0);

 
Dominik Egert #:
Are you on MT4??

Your file shows .mq5

You are using these wrong:
They return a handle and need to go into OnInit.
Then you use CopyBuffer with the handle to get the data from the indicators. - Wondering, you should receive warnings from your compiler....

You need to do some search on the forum about this wrong code (for MQL5):

#property copyright "Copyright 2023, MetaQuotes Software Corp."
#property link      "https://www.mql5.com"
#property version   "1.00"
#property strict

// Define the input parameters
input double lotSize = 0.01;
input double targetProfit = 450;
input double stopLoss = 300;
input int minLots = 2;
input int highPricePips = 10;
input int rsiPeriod = 7;
input int stochKPeriod = 3;
input int stochDPeriod = 3;
input int rsiThreshold = 90;
input int stochThreshold = 90;
input int slippage = 13; // Maximum allowed slippage
input int magicNumber = 12345; // Magic number for trades

double availableBalance;
double maxLotSize;
double tradeLotSize;
int openOrderCount = 0;

// Indicator handles
int rsiHandle, stochHandle;

void OnTick()
{
    double rsiValue[], stochKValue[];
    ArrayResize(rsiValue, 1);
    ArrayResize(stochKValue, 1);

    // Fetch indicator values
    if (CopyBuffer(rsiHandle, 0, 0, 1, rsiValue) != -1 &&
        CopyBuffer(stochHandle, 0, 0, 1, stochKValue) != -1)
    {
        if (rsiValue[0] <= rsiThreshold && stochKValue[0] <= stochThreshold)
        {
            int spread = (int)SymbolInfoInteger(Symbol(), SYMBOL_SPREAD);
            double askPrice = SymbolInfoDouble(Symbol(), SYMBOL_ASK);
            double point = SymbolInfoDouble(Symbol(), SYMBOL_POINT);

            if (spread >= highPricePips * point)
            {
                MqlTradeRequest request;
                MqlTradeResult result;

                request.action = TRADE_ACTION_DEAL;
                request.type = ORDER_TYPE_SELL;
                request.volume = tradeLotSize;
                request.price = askPrice;
                request.deviation = slippage;
                request.magic = magicNumber;
                string comment = "Order Sell v1";
                request.comment = comment;

                bool res = OrderSend(request, result);
                if (!res)
                {
                    Print("Error sending order: ", GetLastError());
                    // Handle the error here
                }
            }
        }
    }

    openOrderCount = OrdersTotal();
}

void OnStart()
{
    // Create handles for the indicators
    rsiHandle = iRSI(NULL, 0, rsiPeriod, PRICE_CLOSE);
    stochHandle = iStochastic(NULL, 0, stochKPeriod, stochDPeriod, MODE_SMA, 0, 0);

    availableBalance = AccountInfoDouble(ACCOUNT_BALANCE);
    double point = SymbolInfoDouble(Symbol(), SYMBOL_POINT);
    maxLotSize = availableBalance * 0.5 / (stopLoss * point);
    tradeLotSize = NormalizeDouble(lotSize, 2);
}


working code

Discover new MetaTrader 5 opportunities with MQL5 community and services
Discover new MetaTrader 5 opportunities with MQL5 community and services
  • 2024.02.18
  • www.mql5.com
MQL5: language of trade strategies built-in the MetaTrader 5 Trading Platform, allows writing your own trading robots, technical indicators, scripts and libraries of functions
 
Leon Nyateka #:


working code

The proper handler is OnInit(). Change the OnStart() to OnInit().

 
//+------------------------------------------------------------------+
//|        Bot de Trading para MT5 - Conexión con API e IA          |
//+------------------------------------------------------------------+
#include <Trade/Trade.mqh>
CTrade trade;

// Parámetros de usuario
input double LotajeMinimo = 0.2;
input double LotajeMaximo = 5.0;
input double Riesgo = 10;    
input double RiskRewardRatio = 1.5; 
input int MaxOperaciones = 100;
input double BeneficioDiario = 150; 

// Filtros de tendencia y volatilidad
input int ADX_Period = 14;
input double ADX_Threshold = 25;

// Variables globales
double BalanceInicial = 0;
bool PuedeOperar = true;
double BeneficioDiaInicio = 0;

//+------------------------------------------------------------------+
//| Función para calcular el lotaje                                 |
//+------------------------------------------------------------------+
double CalcularLote()
{
   double saldo = AccountInfoDouble(ACCOUNT_BALANCE);
   double riesgoUSD = 200 * (Riesgo / 100); 
   double valorPip = SymbolInfoDouble(_Symbol, SYMBOL_TRADE_TICK_VALUE);
   if (valorPip <= 0) return LotajeMinimo; 
   
   double lote = riesgoUSD / (20 * valorPip);
   lote = MathMax(lote, LotajeMinimo);
   lote = MathMin(lote, LotajeMaximo);
   
   Print("Lotaje calculado: ", lote);
   return NormalizeDouble(lote, 2);
}

//+------------------------------------------------------------------+
//| Función para verificar la tendencia con ADX                     |
//+------------------------------------------------------------------+
bool TendenciaFuerte()
{
   double adxBuffer[];
   int handle = iADX(_Symbol, PERIOD_M15, ADX_Period);
   if (handle == INVALID_HANDLE) return false;
   
   ArrayResize(adxBuffer, 1);
   CopyBuffer(handle, 0, 0, 1, adxBuffer);
   IndicatorRelease(handle);
   
   bool tendencia = adxBuffer[0] > ADX_Threshold;
   Print("ADX: ", adxBuffer[0], " - Tendencia fuerte: ", tendencia);
   return tendencia;
}

//+------------------------------------------------------------------+
//| Función para verificar RSI y Bollinger Bands                    |
//+------------------------------------------------------------------+
bool CondicionesExtras()
{
   double rsiBuffer[], bb_upper[], bb_lower[];

   ArrayResize(rsiBuffer, 1);
   ArrayResize(bb_upper, 1);
   ArrayResize(bb_lower, 1);

   int rsiHandle = iRSI(_Symbol, PERIOD_M15, 14, PRICE_CLOSE);
   int bbHandle = iBands(_Symbol, PERIOD_M15, 20, 2, 0, PRICE_CLOSE);
   
   if (rsiHandle == INVALID_HANDLE || bbHandle == INVALID_HANDLE) return false;
   
   CopyBuffer(rsiHandle, 0, 0, 1, rsiBuffer);
   CopyBuffer(bbHandle, 1, 0, 1, bb_upper);
   CopyBuffer(bbHandle, 2, 0, 1, bb_lower);

   IndicatorRelease(rsiHandle);
   IndicatorRelease(bbHandle);
   
   double rsi = rsiBuffer[0];
   double price = SymbolInfoDouble(_Symbol, SYMBOL_BID);
   
   bool condiciones = (rsi > 30 && rsi < 70) && (price > bb_lower[0] && price < bb_upper[0]);
   Print("RSI: ", rsi, " | Precio en Bollinger Bands: ", condiciones);
   
   return condiciones;
}

//+------------------------------------------------------------------+
//| Función para abrir operaciones                                   |
//+------------------------------------------------------------------+
void Operar()
{
   if (PositionsTotal() >= MaxOperaciones || !PuedeOperar) return;
   if (!TendenciaFuerte() || !CondicionesExtras()) return;
   
   double lote = CalcularLote();
   if (lote < LotajeMinimo) return;
   
   double precio = SymbolInfoDouble(_Symbol, SYMBOL_BID);
   double minStop = SymbolInfoDouble(_Symbol, SYMBOL_TRADE_STOPS_LEVEL) * Point();
   if (minStop <= 0) minStop = 1.0 * Point();
   
   double SL = 20 * Point(); 
   double TP = SL * RiskRewardRatio;
   
   double sl = precio - SL;
   double tp = precio + TP;
   
   if (MathAbs(precio - sl) < minStop) sl = precio - minStop;
   if (MathAbs(tp - precio) < minStop) tp = precio + minStop;
   
   if (MathAbs(sl - precio) >= minStop && MathAbs(tp - precio) >= minStop) 
   {
       Print("Intentando abrir una compra con lotaje: ", lote);
       trade.Buy(lote, _Symbol, precio, sl, tp, "Compra ejecutada");
   }
   else
   {
       Print("Stops inválidos. SL: ", sl, " TP: ", tp, " MinStop requerido: ", minStop);
   }
}

//+------------------------------------------------------------------+
//| Función para revisar si se alcanzó el objetivo de ganancias      |
//+------------------------------------------------------------------+
void RevisarGanancias()
{
   double beneficio = AccountInfoDouble(ACCOUNT_PROFIT) - BeneficioDiaInicio;
   Print("Beneficio actual: ", beneficio);
   if (beneficio >= BeneficioDiario)
   {
      PuedeOperar = false;
      Print("Objetivo diario alcanzado. Se detienen las operaciones.");
   }
}

//+------------------------------------------------------------------+
//| Enviar datos a la API de IA                                      |
//+------------------------------------------------------------------+
void EnviarDatosIA()
{
   string headers = "Content-Type: application/json\r\n";
   char result[];
   string result_headers;
   char postData[];
   string jsonData = "{\"symbol\":\"" + _Symbol + "\", \"price\":\"" + DoubleToString(SymbolInfoDouble(_Symbol, SYMBOL_BID), 5) + "\"}";

   StringToCharArray(jsonData, postData);

   int res = WebRequest( 
      "POST", "https://mi-api.com/data", headers, postData, ArraySize(postData), result, result_headers 
   );

   if (res < 0) Print("Error en WebRequest: ", GetLastError());
   else Print("Respuesta de la IA: ", CharArrayToString(result));
}

//+------------------------------------------------------------------+
//| Función principal OnTick                                        |
//+------------------------------------------------------------------+
void OnTick()
{
   if (BalanceInicial == 0)
   {
       BalanceInicial = AccountInfoDouble(ACCOUNT_BALANCE);
       BeneficioDiaInicio = AccountInfoDouble(ACCOUNT_PROFIT);
   }
   RevisarGanancias();
   if (PuedeOperar) 
   {
      Operar();
      EnviarDatosIA(); // Enviar datos a la API de IA
   }
}
Hello; 

Could you help me with these two errors: 'SymbolInfoDouble' - no one of the overloads can be applied to the function call prueba_bot_IA.mq5 104 21 'WebRequest' - no one of the overloads can be applied to the function call prueba_bot_IA.mq5 154 14


SymbolInfoDouble' - no one of the overloads can be applied to the function
SymbolInfoDouble' - no one of the overloads can be applied to the function
  • 2023.07.30
  • Nazar Jawas
  • www.mql5.com
Hi How can solve those errors: First Error: (('SymbolInfoDouble' - no one of the overloads can be applied to the function could be one of 2 functio...
 
Dominik Egert #:
The proper handler is OnInit(). Change the OnStart() to OnInit().

Hello i’m new here and asking for some help with a code I’m having trouble with bear in mind i am not a programmer or developer i’m just passionate about making a working trading bot 
Files:
image.jpg  4802 kb
image.jpg  3062 kb
image.jpg  2381 kb
image.jpg  4249 kb