How To
How to Apply Notification Telegram into EA Auto Trading
#
EA
3 min read
05/10/2022
193
1
0

The following guide helps you to send signals from EA Auto trading to a Telegram Channel.

FXCE EA Dev team have developed the Telegram interaction modules. To send signals from MT5 via Telegram there are 2 stages:

  • Set up Telegram Channel and install Telegram Bot
  • Apply Notify Telegram module to your EA code.

Please follow the steps below to integrate the Notify Telegram code into your EA.

1. Create Telegram Channel, Bot and establish a link between Telegram and MT5

Establish a link between Telegram and MT5:

Tools-> Options-> Expert Advisors -> Allow WebRequest for the following URLs (Add URL: https://api.telegram.org).

Create your own bot in Telegram at @BotFather. Remember Token, it looks something like this 1727473534:AAHksnhD0iLs7vH74OI4n28bITTkrM6.

- Create your channel and make it public.

Start with clicking the menu icon:

Select “Create Channel”.

A new window will come up. Enter your channel name and bio. (See the character limits above.) Click “Create”.

In the next window, choose the type of your channel. If you want your channel to be public, you need to come up with a link for it. In the screenshot below, it’s ”/catmarketing”. If your selected link is unavailable, you’ll need to suggest another option.

Add a bot to your channel and make it an administrator.

As the next step, you can invite up to "bot" to join you channel. Select the users you want to add and click “Invite”. You can skip this step altogether.

As the next step you make it an administrator.

2. Apply Telegram Notification module into your EA Auto Trading code for Developer

2.1. First, download the FxceLibs here.

Uncompressing and copy the folder FxceLibs into the Include folder in MT5, it should be look like the picture below:

2.2. In your EA code, adding Notify code into some code sections below:

a. Include section

You can copy code below:

// ----------------------------- Notify Telegram -----------------------------//
#include <FxceLibs/Common/HistoryPositionInfo.mqh>
#include <FxceLibs/Notification/Telegram/CustomBot.mqh>
#include <FxceLibs/Notification/Telegram/NotifyTelegramChannel.mqh>
 
CNotifyTelegramChannel botChannel;
////////////////////////////////////////////////////////////////////////////////

b. In the Input section  

You can copy code below:

// ----------------------------- Notify Telegram -----------------------------//
input group "Telegram Notification"
input string               InpBotToken       = "xxxxxxxxxx:YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY";   // Bot Token
input string               InpChatId         = "@YourBotChatID";                                   // Bot Chat ID
input string               InpTeamName       = "Team name";                                        // Team Name
input string               InpCopyFee        = "FREE";                                             // Copy Fee
input string               InpLinkFollow     = "https//....";                                      // Link Follow
input string               InpTotalDealsTime = "00:00:00";                                         // Total Deals Time
////////////////////////////////////////////////////////////////////////////////

c. In the OnInit() event

You can copy code below:

// ----------------------------- Notify Telegram -----------------------------//
   
   botChannel.InitializeTelegramBot(InpBotToken);
   botChannel.SetTeamName(InpTeamName);      
   botChannel.SetStatus(InpCopyFee);          
   botChannel.SetLinkAccount(InpLinkFollow); 
   botChannel.SetImageName(_Symbol + ".jpg");

////////////////////////////////////////////////////////////////////////////////

d. In the place order sections

You can copy code below:

// ----------------------------- Notify Telegram -----------------------------//
botChannel.SetType(POSITION_TYPE_BUY);
botChannel.SetEntryPrice(buyPrice);
botChannel.SetStoploss(slPrice);
botChannel.SetTakeprofit(tpPrice);
botChannel.SendToChannel(InpChatId, 0, 1600, 800, ALIGN_CENTER);
////////////////////////////////////////////////////////////////////////////////

e. Where the EA closes Positions / Summarize deals

You can copy code below:

// ----------------------------- Notify Telegram -----------------------------//
botChannel.ShowTotalProfit(InpChatId, InpStartTime, InpTotalDealsTime);
////////////////////////////////////////////////////////////////////////////////

Note:

  • InpStartTime: start trading time

  • InpTotalDealsTime: the Time to Summarize all deals and send the Total to Telegram Channel.

The following is example of the result of Telegram Notification

Good luck and happy trading.

 

 

#FXCEGiga
#Notify
#Notify Signal
#Telegram
#Notification
ic-comment-blueComment
#