WebRequest' - no one of the overloads can be applied to the function call - Can anyone help me fix it?

 

hello master, i got a bug error when creating an custom indicator with telegram notification, with the description ''WebRequest' - no one of the overloads can be applied to the function call", can anyone fix it? i would be very grateful :)

//+------------------------------------------------------------------+
//|                  Stochastic Arrow with LMA Filter                |
//+------------------------------------------------------------------+
#property indicator_chart_window
#property indicator_buffers 2
#property indicator_color1 Blue
#property indicator_color2 Red

extern int KPeriod = 14;
extern int DPeriod = 3;
extern int Slowing = 3;
extern int Overbought = 80;
extern int Oversold = 20;

extern int LMAPeriod = 50;
extern bool UseLMAFilter = true;

extern int SignalMode = 0; // 0=Buy+Sell, 1=Buy Only, 2=Sell Only
extern int StochasticMode = 0;  // 0=Main-Signal Cross, 1=Breakout Limit, 2=Return in Limit

extern string TelegramToken = "YOUR_BOT_TOKEN";
extern string ChatID = "YOUR_CHAT_ID";

double BuyArrow[], SellArrow[];

//+------------------------------------------------------------------+
//| Initialization function                                          |
//+------------------------------------------------------------------+
int OnInit() {
   SetIndexBuffer(0, BuyArrow);
   SetIndexStyle(0, DRAW_ARROW, EMPTY, 2);
   SetIndexArrow(0, 233);

   SetIndexBuffer(1, SellArrow);
   SetIndexStyle(1, DRAW_ARROW, EMPTY, 2);
   SetIndexArrow(1, 234);

   ArraySetAsSeries(BuyArrow, true);
   ArraySetAsSeries(SellArrow, true);

   return(INIT_SUCCEEDED);
}

//+------------------------------------------------------------------+
//| Indicator iteration function                                     |
//+------------------------------------------------------------------+
int OnCalculate(const int rates_total, const int prev_calculated,
                const datetime &time[], const double &open[],
                const double &high[], const double &low[],
                const double &close[], const long &tick_volume[],
                const long &volume[], const int &spread[]) {
   int start = MathMax(prev_calculated - 1, 1);

   for (int i = start; i < rates_total; i++) {
      double K = iStochastic(NULL, 0, KPeriod, DPeriod, Slowing, MODE_SMA, 0, MODE_MAIN, i);
      double D = iStochastic(NULL, 0, KPeriod, DPeriod, Slowing, MODE_SMA, 0, MODE_SIGNAL, i);

      double LMA = iMA(NULL, 0, LMAPeriod, 0, MODE_SMA, PRICE_CLOSE, i);

      // Reset Arrows
      BuyArrow[i] = 0;
      SellArrow[i] = 0;

      // Generate Signals
      bool isBuy = false, isSell = false;

      if (StochasticMode == 0) { // Main-Signal Cross
         if (K > D && iStochastic(NULL, 0, KPeriod, DPeriod, Slowing, MODE_SMA, 0, MODE_MAIN, i + 1) <= iStochastic(NULL, 0, KPeriod, DPeriod, Slowing, MODE_SMA, 0, MODE_SIGNAL, i + 1))
            isBuy = true;
         if (K < D && iStochastic(NULL, 0, KPeriod, DPeriod, Slowing, MODE_SMA, 0, MODE_MAIN, i + 1) >= iStochastic(NULL, 0, KPeriod, DPeriod, Slowing, MODE_SMA, 0, MODE_SIGNAL, i + 1))
            isSell = true;
      } else if (StochasticMode == 1) { // Breakout Limit
         if (K < Oversold)
            isBuy = true;
         if (K > Overbought)
            isSell = true;
      } else if (StochasticMode == 2) { // Return in Limit
         if (K > Oversold && iStochastic(NULL, 0, KPeriod, DPeriod, Slowing, MODE_SMA, 0, MODE_MAIN, i + 1) <= Oversold)
            isBuy = true;
         if (K < Overbought && iStochastic(NULL, 0, KPeriod, DPeriod, Slowing, MODE_SMA, 0, MODE_MAIN, i + 1) >= Overbought)
            isSell = true;
      }

      // Apply LMA Filter
      if (UseLMAFilter) {
         if (close[i] < LMA) isBuy = false; // Price below LMA, ignore Buy
         if (close[i] > LMA) isSell = false; // Price above LMA, ignore Sell
      }

      // Apply Signal Mode Filter
      if (SignalMode == 1) isSell = false;
      if (SignalMode == 2) isBuy = false;

      // Draw Arrows and Send Notifications
      if (isBuy) {
         BuyArrow[i] = Low[i] - (Point * 10);
         SendTelegramMessage(Symbol(), "Buy", TimeToString(time[i], TIME_MINUTES));
      }
      if (isSell) {
         SellArrow[i] = High[i] + (Point * 10);
         SendTelegramMessage(Symbol(), "Sell", TimeToString(time[i], TIME_MINUTES));
      }
   }
   return(rates_total);
}

//+------------------------------------------------------------------+
//| Send Message to Telegram                                         |
//+------------------------------------------------------------------+
void SendTelegramMessage(string pair, string signal, string time) {
   string url = "https://api.telegram.org/bot" + TelegramToken + "/sendMessage?chat_id=" + ChatID + "&text=" +
                "Pair: " + pair + " | Signal: " + signal + " | Time: " + time;
   int timeout = 10;
   char result[];
   int res = WebRequest("GET", url, NULL, 0, NULL, 0, result, timeout);
   if (res <= 0) Print("Telegram Error: ", GetLastError());
}

 

Your code (8 parameters)...

int res = WebRequest("GET", url, NULL, 0, NULL, 0, result, timeout);

Required format (7 parameters)...

int  WebRequest(
   const string      method,           // HTTP method
   const string      url,              // URL
   const string      headers,          // headers 
   int               timeout,          // timeout
   const char        &data[],          // the array of the HTTP message body
   char              &result[],        // an array containing server response data
   string            &result_headers   // headers of server response
   );

Can you spot what's wrong?

When in doubt, consult the documentation first before posting. Just press F1 after clicking on the function name in MetaEditor.

WebRequest - Common Functions - MQL4 Reference
WebRequest - Common Functions - MQL4 Reference
  • docs.mql4.com
WebRequest - Common Functions - MQL4 Reference
 
Your topic has been moved to the section: MQL4 and MetaTrader 4
Please consider which section is most appropriate — https://www.mql5.com/en/forum/172166/page6#comment_49114893
This website uses cookies. Learn more about our Cookies Policy.