1. Introduction
TradingView Subscriber is a tool from VPSTrading.net that functions as a bridge between TradingView (chart & alert platform) and MetaTrader (EA on MT4/MT5). With this tool, you can:
- Receive webhook alerts (JSON) from TradingView via HTTP POST on port 80.
- Relay those webhook alert messages into trade orders for EAs on MT4/MT5.
- Open orders with risk configuration & order management.
2. General Architecture
- Dynamic-Link Library (DLL)
- Executed by the MetaTrader library functions,
TVCopyBridge_x86.dll
for MT4 andTVCopyBridge_x64.dll
for MT5. - Listens for
POST /webhook
requests from TradingView on port 80, in accordance with TradingView's webhook requirements. - Parses the JSON body containing
{ symbol, action, volume, sl, tp }
.
- Executed by the MetaTrader library functions,
- RingBuffer Pub/Sub
- 1 MiB shared memory, very lightweight.
- A head header for each EA subscriber.
- Forwards messages to EA subscribers for processing as orders in MetaTrader.
- Supports up to 16 subscribers (MT4/MT5 EAs).
- EA Subscriber on MT4/MT5
- Import the DLL.
- Register subscribers: Subscriber ID 0 as the parent ID for communication with TradingView.
- Other subscriber IDs start from 1–15. Can be expanded up to 150 subscribers (contact CS).
3. Workflow
- Initialize DLL & EA
The EA with Subscriber ID == 0 starts the HTTP server thread.
All running EA subscribers will automatically consolidate. - TradingView Alert → Webhook
PineScript sends JSON viaalert(json, alert.freq_once_per_bar)
tohttp://<IP-VPS>/webhook
. - HTTP Server Receive & Push
The DLL receivesPOST /webhook
from TradingView, parses the JSON, constructs aTradeMsg
, thenpush(msg)
to EA subscribers to execute BUY/SELL orders. - EA Drain Messages
InOnTick()
:- Match symbols (suffix handling)
- Check drawdown, risk limit, max orders
- Calculate lot size & SL/TP, execute
OrderSend
(MT4) /trade.Buy()/trade.Sell()
(MT5) - Send follow-up alerts (PushNotify/WebhookAPI) if configured
4. Functions & Benefits
Core Functions | Benefits |
---|---|
HTTP Webhook Receiver | Eliminates external polling — TradingView pushes directly to your VPS |
RingBuffer Pub/Sub | Thread-safe & lock-free message handling; supports multiple EAs |
Auto-suffix Matching Symbol | Supports various pair naming conventions (.pro, .micro, .mini, etc.) |
Risk & Drawdown Management | Automatically stops at daily drawdown limit, calculates lot size |
Reverse Orders & Trailing Stop | Flexible trading options: reverse signals, trail SL to breakeven |
Multi-Platform Support | One DLL for MT4 (x86) and MT5 (x64); next update for cTrader & other platforms |
5. How to Use with TradingView
- Copy DLL to VPS/Server
Place the x86 DLL for MT4 and the x64 DLL for MT5 into theMQL4/Libraries
(MT4) orMQL5/Libraries
(MT5) folder on your VPS/server. - Install the EA Subscriber
Copy the TradingView-Subscriber EA to theMQL4/Experts
(MT4) orMQL5/Experts
(MT5) folder. Attach it to the chart and configure the inputs (Subscriber ID
,Suffix
,RiskPercent
, etc.), then click OK.
Attach the EA to an M1 EURUSD chart (for fast ticks) or an M1 BTCUSD chart if alerts come from the BTCUSD pair on TradingView, ensuring ticks continue running over the weekend.
You cannot combine the TradingView-Subscriber EA across MT4 and MT5 platforms. If you run the EA on both MT4 and MT5, only the last platform with the parent Subscriber ID 0 will be forwarded. For example, if you run 10 accounts forwarding alerts from TradingView, and your parent subscriber is on MT4, all 10 accounts will run on MT4 and cannot be mixed with MT5. To run on MT5, all 10 accounts must be on MT5.
- Create an Alert in PineScript
Addalert(json, ...)
in your script; when creating the alert, select “Any alert() function call” and set the Webhook URL tohttp://<IP-VPS>/webhook
.To send JSON alerts to the DLL, include the following code in your PineScript indicator or strategy:
// example buySignal
sl_buy = low[1]
json = '{"symbol":"' + syminfo.ticker + '","action":"BUY","volume":0,"sl":' + str.tostring(sl_buy,"#.#####") + ',"tp":0}'
alert(json, alert.freq_once_per_bar)
// example sellSignal sl_sell = high[1]
json = '{"symbol":"' + syminfo.ticker + '","action":"SELL","volume":0,"sl":' + str.tostring(sl_sell,"#.#####") + ',"tp":0}'
alert(json, alert.freq_once_per_barYou must set the key variables symbol, action, and sl. The volume and tp variables can remain zero.
- Reserve port 80 exclusively for this webhook.
You can do this in the Command Prompt (CMD) by running the following command:
netsh http add urlacl url=http://+:80/webhook/ user=vtadmin listen=yes
- Test & Monitor
Ensure port 80 is open, monitor EA logs in the Experts/Journal tab, and verify drawdown resets & trailing SL.
Conclusion
With TradingView Subscriber, you get real-time, lock-free, multi-subscriber integration between TradingView and MetaTrader. This tool simplifies the implementation of auto-trading from PineScript signals without relying on external services, while providing built-in risk management and high configuration flexibility.