Back to Blog
tradingviewwebhookautomationpine scriptmt4mt5

TradingView to MT4/MT5: Automate Your Alerts with Webhooks

Connect TradingView Pine Script alerts to your MT4 or MT5 account through TradeJournal's webhook endpoint. Full setup guide with example Pine Script.

2026-04-18 8 min readBy TradeJournal Team

If you use TradingView for charting and analysis, you can now automate your alerts directly to MT4 or MT5 through TradeJournal. When your Pine Script strategy generates a signal, TradeJournal receives it and executes the trade on your broker — no manual copying required.

How the Webhook Works

  1. TradingView triggers an alert (from a Pine Script condition or indicator)
  2. TradingView sends a POST request to your TradeJournal webhook URL
  3. TradeJournal parses the signal and queues it for execution
  4. Your MT4/MT5 EA picks up the signal and opens the trade

The webhook removes the manual copy-paste step, but end-to-end timing varies with TradingView delivery, the execution path, network, provider, broker, and market.

Prerequisites

  • A TradeJournal Pro plan (TradingView and other webhook sources are Pro features)
  • A paid TradingView plan (webhook alerts aren't available on TradingView's free plan)
  • MT4 or MT5 EA installed and connected (see Signal Copier setup guide)

Step 1 — Get Your Webhook URL

  1. In TradeJournal, open TradingView Webhook in the sidebar
  2. Copy your unique webhook URL — it looks like:
    https://tradejournalpro.net/api/signals/webhook?token=YOUR_TOKEN
    
  3. Keep this URL private — anyone who has it can send signals to your account

Step 2 — Create a TradingView Alert

In TradingView, open your chart and click the Alert button (clock icon) or press Alt+A.

In the alert dialog:

  • Condition: Select your Pine Script indicator or strategy
  • Action: Check Webhook URL
  • Webhook URL: Paste your TradeJournal webhook URL
  • Message: This is where the signal data goes (see below)

Step 3 — Format the Signal Message

The webhook message must include the signal details. TradeJournal accepts JSON or plain text:

JSON Format (Recommended)

{
  "pair": "XAUUSD",
  "direction": "LONG",
  "entry": {{close}},
  "sl": {{plot("Stop Loss")}},
  "tp1": {{plot("Take Profit 1")}},
  "tp2": {{plot("Take Profit 2")}}
}

TradingView replaces {{close}}, {{plot(...)}} etc. with the actual values when the alert fires.

Plain Text Format

XAUUSD BUY
Entry: {{close}}
SL: {{plot("SL")}}
TP1: {{plot("TP1")}}
TP2: {{plot("TP2")}}

Both formats work. JSON is more reliable for automated parsing.

Step 4 — Pine Script Example

Here's a simple Pine Script strategy that sends signals to TradeJournal:

//@version=5
strategy("TradeJournal Webhook Example", overlay=true)

// Simple MA crossover
fast = ta.ema(close, 9)
slow = ta.ema(close, 21)

longCondition = ta.crossover(fast, slow)
shortCondition = ta.crossunder(fast, slow)

atr = ta.atr(14)
slDistance = atr * 1.5
tpDistance = atr * 3.0

// Build the webhook message in Pine, so the stop and target travel with the order
msg(dir, sl, tp) =>
    '{"pair":"' + syminfo.ticker + '","direction":"' + dir + '","entry":' + str.tostring(close) +
     ',"sl":' + str.tostring(sl) + ',"tp1":' + str.tostring(tp) + '}'

if longCondition
    longSl = close - slDistance
    longTp = close + tpDistance
    strategy.entry("Long", strategy.long, alert_message = msg("BUY", longSl, longTp))
    strategy.exit("Long Exit", "Long", stop = longSl, limit = longTp)

if shortCondition
    shortSl = close + slDistance
    shortTp = close - tpDistance
    strategy.entry("Short", strategy.short, alert_message = msg("SELL", shortSl, shortTp))
    strategy.exit("Short Exit", "Short", stop = shortSl, limit = shortTp)

When you create the alert on this strategy, put only this in the alert's Message box:

{{strategy.order.alert_message}}

TradingView replaces it with the JSON built above for each order. Placeholders can only insert values; they can't calculate, so an expression such as {{close - 10}} won't work. Do the maths in Pine, as here.

Note that the exit orders also fire alerts. Their message is empty unless you give strategy.exit its own alert_message, and an empty message is rejected without opening a trade.

Step 5 — Test the Connection

  1. In TradingView, manually trigger your alert by right-clicking on the chart → Add Alert → set condition to "Once" and save
  2. Check TradeJournal → Signal Copier → Signals — you should see the signal appear within seconds
  3. Verify the parsed values (pair, direction, entry, SL, TP) look correct
  4. If auto-execute is ON for webhook signals, check your MT4/MT5 for the trade

Configuring Webhook Signal Settings

In TradeJournal → Signal Copier → Webhook Settings, you can configure:

  • Auto-execute: Execute immediately or hold for manual approval
  • Default lot size: Used when no lot is specified in the webhook payload
  • Target account: Which EA account(s) receive webhook signals
  • Require confirmation: Get a notification before execution

Supported Signal Fields

FieldRequiredDescription
pairYesTrading pair (XAUUSD, EURUSD, etc.). symbol and ticker also work
directionYesBUY or SELL (also LONG/SHORT, any case). action and side also work
entryNoEntry price (uses market price if omitted)
slNoStop loss price
tp1NoTake profit 1
tp2 through tp5NoAdditional take profit levels
lotNoLot size (overrides account default)
order_typeNoBUY_LIMIT, SELL_LIMIT, BUY_STOP or SELL_STOP for a pending order at entry; market if omitted

Advanced: Multiple Symbols from One Strategy

If your strategy trades multiple symbols, include the symbol dynamically:

{
  "pair": "{{ticker}}",
  "direction": "{{strategy.order.action}}",
  "entry": {{close}}
}

TradingView replaces {{ticker}} with the chart's symbol and {{strategy.order.action}} with buy or sell, which the webhook accepts.

Troubleshooting

Alert fires but no signal in TradeJournal

  • Verify the webhook URL is correct (no extra spaces or line breaks)
  • Check TradingView's alert history for delivery status
  • Make sure the message body is valid JSON if using JSON format

Signal appears but wrong values

  • Check that your Pine Script plots are named correctly
  • Test with a simple fixed-value message first to confirm connectivity

Trade executes at wrong price

  • Webhook signals are market orders by default
  • Add "order_type": "BUY_LIMIT" (or SELL_LIMIT) and an entry price to the payload for a pending order

Keep the URL private

The token in your webhook URL is what lets an alert reach your account, so treat the URL like a password: don't paste it in screenshots, shared scripts or public chats.

Common use cases

  • Run a Pine Script strategy live, hands-free
  • Send a manual chart alert straight to MetaTrader
  • Combine TradingView entries with prop-firm risk limits

Combining Webhooks With Telegram

You can run both simultaneously. Some traders use:

  • TradingView webhook for their own automated strategy
  • Telegram copier for third-party signal channels

Both feed into the same Signals queue, same EA. You get everything in one place.

Get the free Signal Parsing Cheat Sheet

10 real signal formats decoded — plus the free EA copier: 1 channel, 12 signals/month. No card.

The guide does not subscribe you to marketing. Offers are optional.

Test one Telegram channel on demo—free

Never-paid accounts can start with one MT4/MT5 account, one Telegram channel, and 12 EA signals each UTC month. No card is required; paid access does not restart the allowance after expiry.

Get the free EA

No credit card required