MT5 Instant Telegram Notifier - Detail Instructions

MT5 Instant Telegram Notifier - Detail Instructions

25 November 2025, 13:49
Muhammad Iqbal
0
296

TelegramNotifyEA is an Expert Advisor (EA) for MetaTrader 5 (MT5) that automatically sends notifications to a Telegram bot about all trading activities on the MT5 account. The EA monitors changes in positions (open, close, modify) and orders (place, delete, modify), then sends formatted messages to the specified Telegram chats. It can also send chart screenshots as documents with captions when opening positions.

The EA uses WebRequest to communicate with the Telegram Bot API, requiring no external servers. The code is error-free and can be compiled directly in MetaEditor.


Input Parameters

  • botToken  (string): Telegram bot token (required). Obtain from @BotFather on Telegram.
  • chatIds  (string): Telegram chat IDs (required), comma-separated if multiple (e.g., "123456789,987654321").
  • sendChartScreenshot  (bool): If true, send chart screenshot when opening positions; if false, send text messages only.

Setup Requirements

  1. Telegram Bot:

    • Create a bot via @BotFather on Telegram.
    • Get the bot token (e.g.,  123456:ABC-DEF1234ghIkl-zyx57W2v1u123ew11 ).
    • Invite the bot to the chat/group/channel where notifications will be sent.
    • Get chat ID: Send a message to the bot via @username_to_id_bot, then you will find  "Chat id":<number>.
  2. MT5 Setup:

    • Open MT5 Terminal → Tools → Options → Expert Advisors.
    • Check "Allow automated trading".
    • In "Allow WebRequest for listed URLs", click Add and enter  https://api.telegram.org .
    • Restart MT5.
  3. EA Compilation:

How to Use (Instructions)

  1. Attach EA to Chart:

    • Open an MT5 chart (e.g., EURUSD).
    • Drag TelegramNotifyEA.ex5 onto the chart.
    • Set input parameters: botToken, chatIds, sendChartScreenshot.
    • Click OK to attach.
  2. Automatic Operation:

    • EA runs on OnTick, monitoring position/order changes every tick.
    • When trading activity occurs (open position/order), EA sends notifications to Telegram.
    • If sendChartScreenshot = true, chart screenshot is sent as a document with the message as caption.
    • If false, sends text messages only.
  3. Monitor Logs:

    • View Experts → Journal in MT5 for success/failure logs.
    • If failed, check error codes (e.g., 400 for bad request, 413 for file too large).
  4. Detach EA:

    • Right-click chart → Expert Advisors → Remove.

Example Notifications

  • Position Opened (with screenshot):

    • Document: Chart screenshot (PNG, size 800x600).
    • Caption:
      Position Opened:
      📈 BUY
      Ticket: 123456
      Symbol: EURUSD
      Volume: 0.01
      Price: 1.0850
      SL: 1.0800
      TP: 1.0900
  • Position Closed:

    • Message:
      Position Closed:
      Ticket: 123456
      Symbol: EURUSD
      P&L: ✅ +10.50
  • Order Placed:

    • Message:
      Order Placed:
      📈 BUY LIMIT
      Ticket: 789012
      Symbol: GBPUSD
      Volume: 0.02
      Price: 1.2750
      SL: 1.2700
      TP: 1.2800

Troubleshooting

  • No Notifications:

    • Ensure botToken and chatIds are correct.
    • Make sure the bot is admin in the chat/channel.
    • Verify WebRequest is allowed in MT5.
    • Check MT5 logs for errors (e.g., "Failed to send Telegram message").
  • Screenshot Failure:

    • Error "Failed to capture chart screenshot": Chart not active or permission issue.
    • Error "Request Entity Too Large": Screenshot too big (reduce size in code, default 800x600).
    • Error "Bad Request: IMAGE_PROCESS_FAILED": BMP format not supported; EA sends as document.
  • Compilation Errors:

    • Ensure latest MetaEditor version.
    • If undeclared identifier error, check include files.
  • Additional Debug:

    • Uncomment  SendTestDocument()  in OnInit for small upload test.
    • View hex dump in logs for multipart issues.

Additional Notes

  • EA trades only on the attached chart but monitors all positions/orders in the account.
  • Screenshots are temporarily saved in MQL5/Files and deleted after sending.
  • Telegram limits: Caption max 1024 characters, file max 50MB (screenshots usually <1MB).
  • Security: Do not share bot token; use HTTPS.
  • If modifications needed (e.g., message format), edit code and recompile.

The EA is ready for real-time trading notifications via Telegram. If issues arise, provide error logs for further assistance.