
MetaTrader is the most widely used trading platform in retail forex — but its native automation capabilities are limited to MQL scripting. What if you could go beyond that?
By integrating MetaTrader (MT4 or MT5) with n8n, a powerful open-source automation platform, you can build real-time trading workflows that send alerts, trigger bots, log trades, interact with APIs, and much more — all with minimal code.
This guide walks you through how to build advanced trading automations using MetaTrader and n8n.
Table of Contents
What Is n8n?
n8n (pronounced “node-node”) is an extendable workflow automation tool. Think of it like Zapier or Make, but with full customization, developer control, and the ability to run on your own server.
Why use it for trading?
Connect MetaTrader to Telegram, Discord, Google Sheets, Web APIs, databases, and more
Automate responses to price movements, trade signals, or order activity
Build workflows triggered by MetaTrader WebHooks, not just time-based logic
Why Integrate MetaTrader with n8n?
MetaTrader alone is limited to local actions (e.g., placing orders, logging, sending email). With n8n, you can:
Send trading signals to multiple platforms (Telegram, Slack, Email, Discord)
Execute external API calls (to copy trades, trigger bots, or update CRM)
Log all trade activity to databases or Google Sheets
Trigger custom AI responses to trade conditions or client messages
Build multi-account or multi-platform trade copiers
Core Components of the Integration
MetaTrader
MT4 or MT5 terminal with an EA or alert system
Sends trade data via HTTP WebHook
n8n Server or Cloud Instance
Receives WebHook request
Processes logic or routes data to destinations
Output Node(s)
Execute trade, send alert, update log, or take action based on the input
Step-by-Step Guide: MetaTrader → n8n Integration
Step 1: Set Up n8n
You can host n8n:
On a VPS using Docker or Node.js
On n8n cloud (paid plan)
Locally for testing
For VPS hosting, NYCServers offers MetaTrader VPSs that run 24/7 with direct trading platform access.
To start quickly, follow the n8n self-host install guide.
Step 2: Create a WebHook Node in n8n
Open n8n editor
Add a Webhook node
Set method to
POST
and define the path (e.g.,/metatrader-signal
)Save the workflow and copy the WebHook URL
Step 3: Set Up MetaTrader to Send WebHook Alerts
In MetaTrader:
Go to Tools > Options > Notifications (MT5)
Add your n8n WebHook URL to the allowed URL list
Then:
Create an alert or use an EA to send a
POST
request when a trade signal is generatedExample JSON:
{
"symbol": "EURUSD",
"signal": "buy",
"price": 1.0853,
"time": "2025-05-15T14:00:00Z"
}
You can send this using WebRequest()
in MQL5:
string url = "https://your-n8n-server.com/webhook/metatrader-signal";
string data = "{\"symbol\":\"EURUSD\",\"signal\":\"buy\"}";
char post[];
StringToCharArray(data, post);
int res = WebRequest("POST", url, "", "", 0, post, 0, post, NULL);
Step 4: Design Your Workflow in n8n
After receiving the signal, route it through one or more nodes:
If/Else Node – logic based on symbol, price, or direction
HTTP Request Node – call another API (like cTrader, Telegram, Discord, or your broker)
Google Sheets Node – log the signal
Delay/Wait Node – set time-based follow-ups
AI Node (OpenAI or custom) – generate commentary or decisions
Use Case Examples
1. Send Trade Signals to Telegram
MetaTrader → n8n → Telegram Node
Customize the message (symbol, signal, timestamp)
2. Auto-Execute Trade via Another Platform API
MT5 → n8n → Custom REST API (e.g., cTrader Open API)
Maintain multi-platform sync or copy strategy
3. Log Trade Data for Strategy Analysis
MT5 → n8n → MySQL, PostgreSQL, or Google Sheets
Track all trades for performance metrics
4. Trigger a VPS Maintenance or Stop-Loss Command
Trade meets specific loss or drawdown condition
n8n sends a restart or shutdown command to the VPS or sends an alert to the admin
Benefits of Using n8n with MetaTrader
Feature | Benefit |
---|---|
Open-source, self-hosted | Full control, no vendor lock-in |
API integrations | Unlimited destinations |
Real-time WebHooks | Low-latency response |
Visual workflow builder | Easy to use, no deep coding needed |
Event-based logic | Ideal for real-time trade actions |
Hosting It All on a VPS
To make this setup reliable and scalable, host both MetaTrader and n8n on a dedicated VPS.
Why?
Keeps both systems running 24/7
Reduces latency between trading platform and automation logic
Enables direct file/database/API communication without security bottlenecks
Check out NYCServers trading automation VPS →
Final Thoughts
With n8n and MetaTrader working together, you’re no longer limited to local alerts and scripts. You can build a full-featured trading automation infrastructure — one that reacts instantly to market conditions, manages trades across platforms, and integrates seamlessly with your tools.
Whether you’re running a personal algo strategy or building automation for a trading team, this integration puts you in full control.
Want Help Setting It Up?
Our team can help you install, configure, and optimize n8n workflows for MetaTrader — hosted on a fast, secure VPS.