Sunday, June 14, 2020

Send Alerts from Amibroker to Telegram Channel






Create a Public Channel or Private Channel in Telegram

For Public Channel you can get id like @EasySimpleTradeAlerts (https://t.me/EasySimpleTradeAlerts)

For Private Channel, Open userinfobot (@userinfobot) ; /Start ; Type a test message in Private Channel and Post. Then forward that message to this bot and it give you the channel id; it will start -100.. ; Alternatively, if you open the channel in web browser the web address come like this 
https://web.telegram.org/#/im?p=c1234567890_9968066571848700707
take the 10 digits after c and add -100 before it; so you get id as -1001234567890


Now search and open BotFather (@BotFather); Send message /newbot; give name for your bot; give username to your bot; It give API key it is highlighted in red color.


Now open your channel and add your bot to your channel; By default it add as admin.

Now test your Bot can send message. In the following link repalce [BOTKEY] with your Bot API Key and [CHANNEL ID]with your Channel id and paste it in your browser and enter. Now your channel get the message [HELP OTHERS]

https://api.telegram.org/bot[BOTKEY]/sendMessage?chat_id=[CHANNEL ID]&text=[HELP OTHERS] 

Amibroker need to connect internet. So exclude in Firewall.

You can add add any additional info like Entry , SL , Target like following,

BuyPrice = Ref(H,-1);
SL= LLV(L,5);
QTY = 100;//or add some condition
BuyMessage = Name()+”Buy "+QTY+” @ ”+BuyPrice+"SL "+SL;

You can add anything by adding + symbol. But don't put number in first. Strings (word) use within double quote. Value(number) simply add variable name.

For Special Characters use HTML URL Encoding

If the symbol name have like M&M , it ignore & after text, we get only M in the message. So use StrReplace(Name(),"&","%26") instead Name()

For Line break (message come in second line) add  %0A
text = first line%0Asecond line


For Bold Italic Strikethrough use as html format and add " &parse_mode=html "  in last
text=<b>Ohm</b>%0A<i>Murugaa</i>&parse_mode=html

<b>bold</b>  <strong>bold</strong> <i>italic</i> <em>italic</em>
<u>underline</u> <ins>underline</ins> <s>strikethrough</s> <strike>strikethrough</strike> <del>strikethrough</del>
<b>bold <i>italic bold <s>italic bold strikethrough</s> <u>underline italic bold</u></i> bold</b>




Download for versions 6.17 or higher , using InternetOpenUrl

Download for versions before 6.17, using VB Script




Select AFL Time Frame


Set AutoRepeat



Select Apply To and Range as required and Run or Explore