Forex & gold trading signal handler for MT5 using webhooks (telegram/discord)
MT5 Trading Signal Handler Metatrader5 and N8N Integration for Forex and Gold Trading via Webhooks for discord and telegram This n8n template demonstrates a workflow that bridges AI workflows which can be used to comm...
Template notes
MT5 Trading Signal Handler Metatrader5 and N8N Integration for Forex and Gold Trading via Webhooks for discord and telegram
This n8n template demonstrates a workflow that bridges AI workflows which can be used to communicate directly to a trading platform/broker like metatrader 5
Use cases are many:
Try automating TradingView alerts into live MT5 trades, building a custom trading bot that sends trade execution signals to MT5 via webhooks, or creating a centralized signal management system for multiple trading strategies these features are just the beggining!
Good to know
Always test on demo accounts first - start with 1-2% risk before considering any live deployment This workflow uses unauthenticated webhook endpoints by default - you must add authentication (API keys, OAuth) before any production use Signals are stored in n8n's in-memory static data - they will be lost if n8n restarts unless you implement persistent storage MT5 WebRequest whitelist required - you must add all webhook URLs to MT5's allowed URLs list (Tools → Options → Expert Advisors) The workflow requires a custom MT5 Expert Advisor (EA) that polls the GET endpoint every 5 seconds to fetch pending signals This is designed for local machine or private VPS deployment only - not suitable for public cloud without significant security hardening No automatic signal expiration - old signals will accumulate without manual cleanup or additional workflow logic Compatible with standard MT5 brokers that support automated trading and WebRequest functionality
How it works
Signal Reception: The "Receive Signal (POST)" webhook accepts trading signals containing asset, entry price, stop loss, take profit, and risk percentage, then passes them to the "Store Signal" Code node Signal Storage: The Code node creates a unique signal ID with timestamp, stores it in n8n's workflow static data with "pending" status, and returns a success response with the signal ID Queue Polling: The "Get Pending Signals (GET)" webhook is polled every 5 seconds by your MT5 Expert Advisor to check for new signals Signal Retrieval: The "Fetch Pending Signals" Code node filters all stored signals to return only those with "pending" status as a JSON array Market Orders: The "Market Order (POST)" webhook accepts instant-execution orders with direction (BUY/SELL), risk percentage, and stop loss in pips, calculating SL/TP prices automatically Limit Orders: The "Limit Order (POST)" webhook handles pending orders with specific entry prices, converting pip-based SL/TP into actual price levels for both standard and JPY pairs Trade Confirmation: After the MT5 EA executes a trade, it sends the signal ID to the "Confirm Signal Processed (POST)" webhook, which marks the signal as "processed" and removes it from the pending queue Emergency Cleanup: The "Clear all signals (POST)" webhook provides a reset function to remove all signals from the queue, useful for testing or when signals get stuck