AFL to Telegram Messages -- Error Multiple MSG sent

Hi All,
I have the code below which is sending multiple telegram messages in 5 mins time frame.

Someone please update the code so it can send only 1 message per Candle BAR.

TelegramAlerts = ParamTrigger("Telegram Alert","Send Alert");
TelegramAPI_ID = ParamStr("Telegram Bot API Key","1046872120:wwwwwn_TVmddddGfUlmc"); //Get the Bot API key via BotFather in Telgram
TelgramCHAT_ID = ParamStr("Telegram Channel ID","4xxxxx5"); //Channel ID
Message = "Check this Stock "+Name();
TelegramAlerts1 = InternetOpenURL("https://api.telegram.org/bot"+TelegramAPI_ID+"/sendMessage?chat_id="+TelgramCHAT_ID+"&text= "+Message );
AlertIf((Buy), "EXEC TelegramAlerts1","Tele Alert", 3);
InternetClose(TelegramAlerts1);

Thanks a lot in advance
CL

first you'll need to decide ... either you use AlertIf(EXEC ...), or InternetOpenURL()

lets consider we use only

AlertIf(EXEC

and still i face multiple msg on telegram

Hi Rottor,

I have managed to get proper Telegram messages with your HINT,.. I have a new problem .. it works properly in 1 min chart and i get 1 telegram message in 1 min. But when in 5 mins chart, I get 10 telegram messages till the bar is over. So need to minimize the number of telegram messages..PLEASE GUIDE...

HERE is the code

if( LastValue( Buy ) )
{
TelegramAlertsBuy = InternetOpenURL("https://api.telegram.org/bot"+TelegramAPI_ID+"/sendMessage?chat_id="+TelgramCHAT_ID+"&text= "+MessageBUY );
InternetClose(TelegramAlertsBUY);
}

if( LastValue( Sell ) )
{
Sell = ExRem (Sell,Buy);
TelegramAlertsSELL = InternetOpenURL("https://api.telegram.org/bot"+TelegramAPI_ID+"/sendMessage?chat_id="+TelgramCHAT_ID+"&text= "+MessageSELL );
InternetClose(TelegramAlertsSELL);
}

Read this ....

https://www.amibroker.com/guide/afl/staticvarset.html

and the example in the end of this

https://www.amibroker.com/guide/afl/say.html

Can you please give me the correct working code.. i couldnt get it RIGHT ... plz plz guide

@chaaranpall,

See