We Announce FREE e-Course 'Cara Profesional Trader Menggunakan Server Trading'
Pelajari konfig penting yang harus ada di server trading, standard expert advisor yang wajib Anda ketahui sebelum menjalankannya, tool penting yang wajib dijalankan dan bagaimana menjalankan server trading pintar yang bisa auto recovery pada saat terjadi disaster pada server. Klik disini untuk mendaftar kursus ini GRATIS.

TradingView Subscriber: Turn TradingView Alerts into Orders on MT4/MT5

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

  1. Dynamic-Link Library (DLL)
    • Executed by the MetaTrader library functions, TVCopyBridge_x86.dll for MT4 and TVCopyBridge_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 }.
  2. 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).
  3. 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

  1. Initialize DLL & EA
    The EA with Subscriber ID == 0 starts the HTTP server thread.
    All running EA subscribers will automatically consolidate.
  2. TradingView Alert → Webhook
    PineScript sends JSON via alert(json, alert.freq_once_per_bar) to http://<IP-VPS>/webhook.
  3. HTTP Server Receive & Push
    The DLL receives POST /webhook from TradingView, parses the JSON, constructs a TradeMsg, then push(msg) to EA subscribers to execute BUY/SELL orders.
  4. EA Drain Messages
    In OnTick():
    • 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

  1. Copy DLL to VPS/Server
    Place the x86 DLL for MT4 and the x64 DLL for MT5 into the MQL4/Libraries (MT4) or MQL5/Libraries (MT5) folder on your VPS/server.
  2. Install the EA Subscriber
    Copy the TradingView-Subscriber EA to the MQL4/Experts (MT4) or MQL5/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.

  3. Create an Alert in PineScript
    Add alert(json, ...) in your script; when creating the alert, select “Any alert() function call” and set the Webhook URL to http://<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_bar

    You must set the key variables symbol, action, and sl. The volume and tp variables can remain zero.

  4. 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

  5. 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.

Download

TradingView Subscriber 4 for MetaTrader 4

TradingView Subscriber 5 for MetaTrader 5

  • TradingView copy trade, tradingview alert
  • 3 Users Found This Useful
Was this answer helpful?