Private Trade Alerts to Telegram
- Yardımcı programlar
-
Themistokli Kola
MQL4 / MQL5 and Pine Script developer.
What I do:
- Pine Script to MQL5 / MQL4 conversions (TradingView indicators and strategies into MT5/MT4 indicators or EAs)
- Fixes and changes to existing EAs and indicators: bugs, new inputs, filters, daily limits, breakeven and trailing logic - Sürüm: 1.0
- Etkinleştirmeler: 5
Private Trade Alerts to Telegram sends the events of your own MetaTrader 5 account to your own Telegram chat, through your own Telegram bot: positions opened and closed, partial closes, SL and TP changes, pending orders, a daily summary and optional warnings. It only reports what happened on the account. It never opens, changes or closes a trade, and it gives no signals or advice.
Setup in 5 steps
- Create your bot. In Telegram, open the official BotFather chat, send the newbot command and follow the questions. It gives you a bot token (two parts joined by a colon). Keep it private: anyone with it can send as your bot.
- Find your chat id. Send any message to your new bot, then find your numeric chat id, for example with a chat-id helper bot in Telegram. For a private group, add the bot to the group; group ids start with a minus sign.
- Allow the Telegram address in MetaTrader 5. In Tools, Options, Expert Advisors, tick "Allow WebRequest for listed URL" and add the Telegram Bot API address. The exact address is shown on the panel and in the Experts log when it is missing, so you can copy it from there.
- Attach the EA. Drag Private Trade Alerts to Telegram onto any one chart of the account. Enter the Bot token and Chat id, choose the events you want, and press OK. One chart per account is enough: the EA reports every symbol of the account unless you filter them.
- Check the test message. With "Send a test message on start" on, "Alerts started" arrives in your chat within a few seconds and the panel shows Status: Ready. Leave the chart open: alerts are sent while the terminal runs.
Telegram settings
- Bot token - the token from step 1. Only its last 4 characters are ever shown on the panel or in the log.
- Chat id - your chat id from step 2.
- Second chat id (optional) - a second destination, for example a private group. Every message goes to both.
- Send a test message on start - sends "Alerts started" each time the EA starts, so you can see the connection works.
- Use HTML formatting - shows the message titles in bold. Off = plain text.
Events
- Positions opened - symbol, buy or sell, volume, price, SL, TP, magic number or "manual", comment, time.
- Closes and partial closes - closed volume, close price, opening price, result in the account currency and optionally in points, and the reason: by hand, by an Expert Advisor, SL hit, TP hit, stop out. A partial close also shows the remaining volume.
- SL and TP changes - old and new SL and TP of the position.
- Pending orders - placed, modified (old and new price, SL, TP), deleted, expired. A filled pending order is reported as "Pending order filled - position opened".
- Daily summary - once a day: closed trades of the day, sum of their results, balance, equity and open positions.
- Daily summary time - HH:MM in terminal (trade server) time, for example 23:55. If the EA is started after this time, that day's summary is skipped rather than sent late.
- Margin level warning below this % - a warning when the margin level falls below this value, only while positions are open. It is sent again only after the level has recovered. 0 = off.
- Daily equity drop warning % - a warning, once a day, when equity is this many percent below the equity at the start of the day. 0 = off.
- Alert when the terminal reconnects - a message after the connection to the trade server was lost for more than a few seconds and came back.
- Heartbeat message every N hours - a short "alerts are running" message with balance and equity. 0 = off.
Filters and format
- Symbols - comma-separated list, for example EURUSD,XAUUSD. Empty = all symbols.
- Magic number - report only trades of this Expert Advisor magic number; -1 = all.
- Include manual trades - report trades opened by hand (magic number 0).
- Account label - shown at the top of every message in square brackets. Empty = "Account ****" and the last 4 digits of the account number.
- Show results in points too - adds the result in points to close messages.
- Time zone shift for message times - hours added to the times shown in messages.
- Show panel, Panel X, Panel Y - the small panel on the chart and its position. The minus button collapses it to one line, the plus button opens it again.
The panel
Product name; status (Ready, Sending, Add the Telegram address in Options, Token or chat id missing, Bot token rejected by Telegram, Tester: sending off); chat and token (last 4 characters only); messages sent today and the queue length; the time of the last message; and the last error in plain words.
Sending, limits and errors
- Messages wait in a queue and are sent one per second, at most 20 per minute (Telegram's own limits). The queue holds up to 200 messages; beyond that the oldest is dropped and the Experts log says so.
- If Telegram asks to slow down, or the network fails, the message is retried after a short wait.
- If the WebRequest permission is missing, the panel and the Experts log name the address to add; messages wait in the queue and are sent once the address is allowed.
- If Telegram rejects the bot token, sending stops and the panel says so; correct the token in the inputs.
- Events that happen while the terminal is closed are not sent later. After a restart the EA does not resend old events.
- In the Strategy Tester nothing is sent, because WebRequest does not work there; the Experts log says so once.
