MT4 to Telegramm Message \n doesn't work - page 2

 
DZiggler #:
You just saved my life man/girl

Do you mind sharing how you went about it beacause it doesnt work for me


 
NabiKAZ #:

You can use %250A for break new line in message was sent.


It works thank you.


Why %250a and not %0a like using the api outside MT4 ?

 
NabiKAZ #:

You can use %250A for break new line in message was sent.

it works, many thanks ;-)
 
Likely the \n simply doesn't allowed to exist in URL, it might implicitly gets converted by MQL4 to encoded character like %5C, or it might just passed to the endpoint which didn't expect to process the weird URL. This problem shall persists as long as one using query string to pass the web request data.

Besides, I confirmed that when sending request via Postman, the \n in the message body works fine without the need of specifying parse_mode.
 
All you have to do is use %0A . It took me ages to find this on the internet and don't add the full stop.
 

LAST MESSAGE WORK GREAT THANK´S A LOT


MQL5 CODE

//--------SEND BUY TO  TELEGRAM-------

  char data[];

                  char res[];

                  string resHeaders;

                  double current_bid = SymbolInfoDouble(_Symbol, SYMBOL_BID);

                  

                  //string msg = "BUY SIGNAL GENERATED ON CHART "+_Symbol ;

                  string msg = "BUY "+_Symbol+" @"+current_bid+"%0A"+" Stop Loss at:"+NivelSLCompra(StopLoss)+"%0A"+" Take Profit 1 at: "+NivelTPCompra(TakeProfit);

                            

                  

                  //https://api.telegram.org/bot{HTTP_API_TOKEN}/sendmessage?chat_id={CHAT_ID}&text={MESSAGE_TEXT}

                  const string url = TG_API_URL+"/bot"+botTkn+"/sendmessage?chat_id="+chatID+

                  "&text="+msg;

                  int send_res = WebRequest("POST",url,"",10000,data,res,resHeaders);

                  

                  if (send_res == 200){

                     Print("TG MSG SENT SUCCESSFULLY");

                  }

                  else if (send_res == -1){

                     if (GetLastError()==4014){

                        Print("PLEASE ADD THE ",TG_API_URL," TO THE TERMINAL");

                     }

                     Print("UNABLE TO SEND THE TG MSG");

                  }

                  else if (send_res != 200){

                     Print("UNEXPECTED RESPONSE ",send_res," ERR CODE = ",GetLastError());

                  }

            

 

work fine