Watch how to download trading robots for free
Find us on Facebook!
Join our fan page
Interesting script?
So post a link to it -
let others appraise it
You liked the script? Try it in the MetaTrader 5 terminal
Libraries

Telegram Notify - trade notifications, chart screenshots and daily summary for any EA (library + ready EA) - library for MetaTrader 5

Views:
50
Rating:
(1)
Published:
\MQL5\Include\
MQL5 Freelance Need a robot or indicator based on this code? Order it on Freelance Go to Freelance
TelegramNotify

TelegramNotify_chart

Two files:
- TelegramNotify.mqh - the library. Put it in MQL5\Include.
- TelegramTradeNotifier.mq5 - a ready EA built on the library. Attach it to one chart and it reports all trades of the account (manual trades and other EAs). It never trades.

What it sends:
- Opened position: side, volume, symbol, price, SL, TP, ticket, magic, comment.
- Closed position (full or partial): net result in money (profit + swap + commission), points, open price, holding time, close reason (Stop Loss, Take Profit, Stop Out, EA, manual desktop/mobile/web), balance.
- SL/TP changes: old -> new value. Checked every second, so it catches changes made by hand, by any EA or by the broker. Limited to one message per position per N seconds, so trailing stops do not flood the chat.
- Pending orders: placed, deleted, expired, rejected.
- Summary once a day at a chosen server time: closed trades, win rate, net result, open positions and floating P/L, balance, equity, margin level. Each summary starts where the previous one ended, so no trade is lost between summaries. Days without trades can be skipped.
- Chart screenshot on open and/or close (optional). The picture is taken from an open chart of the trade's symbol. Without one, the text message is sent.

Library features:
- Send() for plain text, SendHtml() for bold, italic, code and links, SendPhoto() for any picture in MQL5\Files, SendChart() for a chart screenshot.
- Outgoing queue (50 messages). When there is no internet or Telegram is busy, messages are kept and retried. Telegram's "Too Many Requests" answer is respected.
- About 1 message per second, the limit Telegram allows per chat.
- Messages longer than 4096 characters are split on line breaks.
- Clear errors in the journal: "WebRequest not allowed", wrong token, wrong chat id.
- Strategy Tester: WebRequest does not work there, so messages are printed to the journal (dry run). You can check what your EA would send before running it live.

Use in your own EA:

#include <TelegramNotify.mqh>

CTelegramBot   tg;
CTradeNotifier trades;

int OnInit()
{
   tg.Init("123456:ABC...", "123456789", "MyEA XAUUSD");
   trades.Init(&tg, 12345);              // magic of your EA (-1 = all trades)
   trades.Events(true, true, false, false);
   trades.DailySummary(23, 50);
   EventSetTimer(1);
   tg.Send("EA started");
   return INIT_SUCCEEDED;
}
void OnTimer() { trades.OnTimer(); }     // retries + summary + SL/TP check
void OnTradeTransaction(const MqlTradeTransaction &t, const MqlTradeRequest &q, const MqlTradeResult &r)
{
   trades.OnTransaction(t);
}

Setup:

1. In Telegram, open @BotFather, send /newbot and copy the token.

2. Send any message to your new bot. To find your chat id, open https://api.telegram.org/bot<TOKEN>/getUpdates in a browser and look for "chat":{"id":... For a group, add the bot to the group, write in the group and use the (negative) id. For a channel, make the bot an admin.

3. MetaTrader: Tools > Options > Expert Advisors > check "Allow WebRequest for listed URL" and add https://api.telegram.org


Notes:

- Sending takes a short time (WebRequest is synchronous). Messages are sent from OnTradeTransaction and OnTimer, not from OnTick.

- Times in messages are broker server time.

- Keep your bot token private. Do not share .set files that contain it.

XAUUSD Hang Seng Split: a free gold EA that reads the Hong Kong market XAUUSD Hang Seng Split: a free gold EA that reads the Hong Kong market

This is a free, execution only EA for gold on M15. It compares gold with the Hang Seng (HK50). When gold has split far away from it, the EA trades in the direction of that split, but only while gold itself is calm and hasn't already made the move.

Equity Guard Equity Guard

Closes all positions, deletes pending orders and blocks new trades when the daily loss, drawdown-from-peak or daily profit target is reached. Works with manual trading and any other EA. State survives terminal restart.

Symbol and Trading Conditions Inspector Symbol and Trading Conditions Inspector

Displays live symbol specifications, broker trading conditions, account information, spread, trading permissions, session status and margin properties directly on the MT5 chart.

Risk Calculator - lot size by risk percent and ATR stop Risk Calculator - lot size by risk percent and ATR stop

On-chart panel that sizes your trade: lot size from your risk % and a stop in points or ATR, with spread, broker-minimum, minimum-lot and margin checks. Calculation only - it never trades.