TradingView is where many traders do their analysis, build strategies with Pine Script, and set up alerts. But TradingView itself does not execute trades — it sends signals. To turn those signals into actual positions at your broker, you need a webhook receiver running on a server that is online 24/7. That is where your VPS comes in.
This guide explains the architecture, walks through setting up a webhook receiver on your FXVPS server, and covers the security considerations you need to get right.
How TradingView Webhooks Work
The flow is straightforward:
- You create a TradingView alert (based on a price level, indicator condition, or Pine Script strategy).
- The alert triggers and sends an HTTP POST request to a URL you specify — the webhook.
- Your VPS receives that POST request, parses the data, and executes a trade through your broker’s API.
💡 Tip: TradingView webhook alerts require a publicly accessible endpoint on your VPS. Run your webhook receiver as a Windows service so it auto-starts after reboots and doesn’t depend on an active RDP session.
TradingView runs in the cloud. Your VPS runs the webhook receiver. You do not install TradingView on your VPS. You use TradingView in your browser (on your laptop, phone, wherever), but the webhook endpoint that receives the signals lives on your VPS.
This is different from running MetaTrader or cTrader on a VPS, where the entire trading platform runs on the server. With TradingView webhooks, the VPS acts as a lightweight trade execution relay.
Why You Need a VPS for This
The webhook receiver must be online at all times. If it goes down, TradingView still sends the alert — but nobody is listening, and the trade does not get executed. You lose the signal.
Running a webhook server on your home computer has the same problems as running any trading platform at home: internet drops, power outages, your PC going to sleep, and your IP address changing if you do not have a static IP.
A VPS solves all of this. It runs 24/7 in a datacenter with redundant power and networking, it has a fixed IP address, and FXVPS servers are positioned in financial hubs (London LD4, New York NY4, Tokyo TY3, Hong Kong HK1) for low latency to your broker’s servers.
📊 Key Stat: Major forex brokers cluster in a handful of Equinix datacenters (LD4 London, NY4 New York, TY3 Tokyo). A VPS in the same facility achieves sub-millisecond latency because data travels meters, not continents.
Setting Up a Webhook Receiver
There are several approaches, from writing your own code to using pre-built tools. Here are the main options.
Option 1: Python with FastAPI (Recommended)
This is the most flexible approach. You write a small Python server that listens for TradingView webhooks and executes trades.
Step 1: Install Python on your VPS.
Download Python from python.org and install it on your VPS. During installation, check “Add Python to PATH.” Verify by opening Command Prompt and typing python --version.
Step 2: Install required packages.
Open Command Prompt on your VPS and run:
pip install fastapi uvicorn
For broker connectivity, install the relevant package:
- MetaTrader 5:
pip install MetaTrader5(see our MT5 setup guide for platform installation) - For crypto exchanges:
pip install ccxt - For brokers with REST APIs:
pip install requests(works with Oanda and Forex.com APIs)
✅ Best Practice: Store exchange API keys with withdrawal permissions disabled on your VPS. If your VPS is ever compromised, the attacker can at most place trades — they cannot withdraw your funds.
Step 3: Create the webhook server.
Create a file called webhook_server.py on your VPS:
from fastapi import FastAPI, Request
import json
app = FastAPI()
SECRET_TOKEN = "your-secret-token-here"
@app.post("/webhook/{token}")
async def receive_signal(token: str, request: Request):
if token != SECRET_TOKEN:
return {"status": "unauthorized"}
data = await request.json()
action = data.get("action") # "buy" or "sell"
symbol = data.get("symbol") # "EURUSD"
qty = data.get("qty", 0.1) # lot size
# Execute trade through your broker API here
print(f"Signal received: {action} {qty} {symbol}")
# Example with MetaTrader 5:
# import MetaTrader5 as mt5
# mt5.initialize()
# request = {
# "action": mt5.TRADE_ACTION_DEAL,
# "symbol": symbol,
# "volume": qty,
# "type": mt5.ORDER_TYPE_BUY if action == "buy" else mt5.ORDER_TYPE_SELL,
# "type_filling": mt5.ORDER_FILLING_IOC,
# }
# result = mt5.order_send(request)
return {"status": "ok", "action": action, "symbol": symbol}
Step 4: Run the server.
python -m uvicorn webhook_server:app --host 0.0.0.0 --port 8080
Your webhook URL is now: http://YOUR_VPS_IP:8080/webhook/your-secret-token-here
Option 2: Pre-Built Bridge Tools
If you do not want to write code, several pre-built tools connect TradingView to MetaTrader:
- TradingView-to-MT4/MT5 bridges: Tools like TV2MT or similar relay services act as middleware between TradingView webhooks and MetaTrader’s order system. Install these on your VPS alongside MetaTrader.
- Webhook relay services: Some third-party services receive the webhook for you and forward it to your broker. The downside is added latency and dependence on a third party.
Pre-built tools are faster to set up but give you less control over signal parsing, risk management logic, and error handling. For most traders, the Python approach above is worth the small extra effort.
Option 3: Node.js Webhook Server
If you are more comfortable with JavaScript:
const express = require('express');
const app = express();
app.use(express.json());
const SECRET = 'your-secret-token-here';
app.post('/webhook/:token', (req, res) => {
if (req.params.token !== SECRET) {
return res.status(401).json({ status: 'unauthorized' });
}
const { action, symbol, qty } = req.body;
console.log(`Signal: ${action} ${qty} ${symbol}`);
// Execute trade through broker API here
res.json({ status: 'ok' });
});
app.listen(8080, '0.0.0.0', () => {
console.log('Webhook server running on port 8080');
});
Install Node.js on your VPS, save this as server.js, install Express with npm install express, and run with node server.js.
Configuring TradingView Alerts
With your webhook server running on the VPS, set up the alert in TradingView:
- Open TradingView in your browser (on your PC or phone — not on the VPS).
- Right-click on a chart or go to the Alerts panel and click Create Alert.
- Set your alert condition (price crossing a level, indicator signal, Pine Script strategy alert).
- In the Notifications section, check Webhook URL.
- Enter your VPS webhook URL:
http://YOUR_VPS_IP:8080/webhook/your-secret-token-here - In the Alert message field, enter the JSON payload your server expects:
{"action": "buy", "symbol": "EURUSD", "qty": 0.1}
For Pine Script strategies, you can use TradingView’s built-in placeholders:
{"action": "{{strategy.order.action}}", "symbol": "{{ticker}}", "qty": 0.1}
Click Create and the alert is live. When it triggers, TradingView sends the JSON to your VPS, your server parses it, and the trade executes.
Note: TradingView webhook alerts require a paid TradingView plan (Pro, Pro+, or Premium). The free plan does not support webhooks.
Security Considerations
Your webhook server is exposed to the internet, which means you need to think about security.
Use a Secret Token
Never use a plain webhook URL like http://YOUR_VPS_IP:8080/webhook. Always include a secret token in the URL path (as shown in the examples above) or in a custom header. This prevents random bots from sending fake trade signals to your server.
Generate a strong token — 32+ characters of random alphanumeric text. Do not use “password123.”
✅ Best Practice: Use a unique, 16+ character password for your VPS and change it every 90 days. Never reuse your broker login password for VPS access — a compromised VPS password should never expose your trading accounts.
Firewall Configuration
TradingView sends webhooks from a known set of IP addresses. You can restrict your VPS firewall to only accept incoming connections on your webhook port from TradingView’s IP ranges. Check TradingView’s documentation for their current webhook source IPs.
On your VPS, open Windows Firewall with Advanced Security:
- Create a new Inbound Rule.
- Select Port, enter your webhook port (e.g., 8080).
- Under Scope, add TradingView’s IP addresses to the “Remote IP address” list.
- Allow the connection only from those IPs.
HTTPS Encryption
HTTP sends data in plain text. If your webhook payload includes sensitive information, use HTTPS instead. You can set up HTTPS with a self-signed certificate or use a reverse proxy like Caddy (which handles HTTPS automatically with Let’s Encrypt).
For most traders, the secret token approach is sufficient security. HTTPS adds protection against network-level eavesdropping, which is important if you are passing account credentials in the payload (though you should avoid doing that — keep credentials stored on the VPS, not in the webhook payload).
Validate Incoming Data
Your webhook server should validate every field in the incoming JSON before executing a trade. Check that the action is “buy” or “sell” (not something unexpected), the symbol exists at your broker, and the quantity is within your risk limits. Never blindly execute whatever the webhook sends.
Running the Webhook Server 24/7
A webhook server that stops running is useless. Here is how to keep it alive on your VPS.
Method 1: NSSM (Recommended)
NSSM (Non-Sucking Service Manager) turns any executable into a Windows service that starts automatically and restarts on crash.
- Download NSSM from nssm.cc.
- Open Command Prompt as Administrator.
- Run:
nssm install WebhookServer - Set the Path to your Python executable (e.g.,
C:\Python312\python.exe). - Set Arguments to
-m uvicorn webhook_server:app --host 0.0.0.0 --port 8080. - Set the Startup directory to the folder containing your
webhook_server.py. - Click Install service, then start it with
nssm start WebhookServer.
The server now runs as a Windows service — it starts on boot and restarts automatically if it crashes.
Method 2: Task Scheduler
- Open Task Scheduler on your VPS.
- Create a new task that runs at system startup.
- Set the action to run your Python script or Node.js server.
- Under Settings, check “If the task fails, restart every 1 minute.”
Task Scheduler works but is less robust than NSSM for keeping a server process alive.
Recommended FXVPS Plan
A webhook server by itself is lightweight — it uses minimal RAM and CPU. The resource requirements depend on what else runs alongside it:
- Webhook server only (broker API execution): Core plan ($29/mo) — more than enough for a Python/Node.js webhook server.
- Webhook server + MetaTrader (for MT5 Python package execution): Core plan or Pro plan depending on how many MT5 terminals you run.
- Webhook server + multiple trading platforms: Pro plan ($39/mo) or Scaling plan ($79/mo) depending on total resource needs.
The key advantage of running your webhook receiver on FXVPS is location. With datacenters in London (LD4), New York (NY4), Tokyo (TY3), and Hong Kong (HK1), the signal path from TradingView to your VPS to your broker stays fast — with latency as low as 0.38ms to supported brokers.
Turn your TradingView alerts into executed trades. Get your FXVPS plan and set up your webhook server today.
Related Reading
- MT5 Setup and Optimization on VPS — run MetaTrader 5 alongside your webhook server
- cTrader on VPS: Complete Guide — alternative platform with built-in copy trading
- NinjaTrader 8 VPS Setup Guide — for futures traders using TradingView for analysis
- Running Multiple MT4/MT5 Terminals on VPS — combine webhook automation with multiple broker terminals