why my expert advisor doesnt send messages?

 

hi guys, i made an expert advisor using an indicator, every time a buy signal is detected the ea sends a message to a telegram channel i made, and is the same for sell signals. the problem is that it does not send the message, i know its not the web requests because it sends a message successfully everytime after initializing the ea, and also i know the handler and getting the indicator data works fine so i dont know whats wrong. im tired of expert advisors not working without knowing why, thats why i ask for your help

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

#include <Trade/Trade.mqh>

int handle;
CTrade trade;
string Tradetype;
string id = "***************";
string token = "**************************";

int OnInit()
  {
   handle = iCustom(_Symbol, PERIOD_CURRENT, "Market//Boom and crash smasher", 8, 1);
   
   string texto = "Hola mundo";
   sendmessage(texto, id, token);
  
   return(INIT_SUCCEEDED);
  }

int sendmessage(string text, string chatid, string Bottoken){
   string baseurl = "https://api.telegram.org";
   string headers = "";
   string requestUrl = "";
   string requestHeaders = "";
   char resultdata[];
   char posdata[];
   int timeout = 2000;
   
   requestUrl = StringFormat("%s/bot%s/sendmessage?chat_id=%s&text=%s", baseurl, Bottoken, chatid, text);
   
   int response = WebRequest("POST", requestUrl, headers, timeout, posdata, resultdata, requestHeaders);
   string resultmessage = CharArrayToString(resultdata);
   Print(resultmessage);
   
   return response;
   
}

void OnTick(){
   
   double arrSellSignals[];
   ArraySetAsSeries(arrSellSignals, true);
   CopyBuffer(handle, 0, 0, 1, arrSellSignals);
   
   double arrBuySignals[];
   ArraySetAsSeries(arrBuySignals, true);
   CopyBuffer(handle, 1, 0, 1, arrBuySignals);
   
   if(arrSellSignals[0] > 0){
      if(Tradetype == "BUY"){
         sendmessage("SELL", id, token);
         Tradetype = "SELL";
      }
   }
      
   if(arrBuySignals[0] > 0){
      if(Tradetype == "SELL"){
         sendmessage("BUY", id, token);
         Tradetype = "BUY";
      }
   }
}
   
 
Your topic has been moved to the section: Expert Advisors and Automated Trading
Please consider which section is most appropriate — https://www.mql5.com/en/forum/172166/page6#comment_49114893
MQL5 forum: Expert Advisors and Automated Trading
MQL5 forum: Expert Advisors and Automated Trading
  • www.mql5.com
How to create an Expert Advisor (a trading robot) for Forex trading