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().