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 whole cycle takes under 3 seconds from alert to execution.

Prerequisites

  • TradeJournal Pro account
  • TradingView account (Pro, Pro+, or Premium โ€” alerts require a paid plan)
  • MT4 or MT5 EA installed and connected (see Signal Copier setup guide)

Step 1 โ€” Get Your Webhook URL

  1. Go to TradeJournal โ†’ Signal Copier โ†’ Webhook
  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

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

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

For the alert message on strategy.entry:

{
  "pair": "XAUUSD",
  "direction": "{{strategy.order.action == "buy" ? "LONG" : "SHORT"}}",
  "entry": {{close}},
  "sl": {{strategy.order.action == "buy" ? close - (ta.atr(14) * 1.5) : close + (ta.atr(14) * 1.5)}},
  "tp1": {{strategy.order.action == "buy" ? close + (ta.atr(14) * 3.0) : close - (ta.atr(14) * 3.0)}}
}

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.)
directionYesLONG or SHORT (also accepts BUY/SELL)
entryNoEntry price (uses market price if omitted)
slNoStop loss price
tp1NoTake profit 1
tp2 through tp5NoAdditional take profit levels
lotNoLot size (overrides account default)
commentNoTrade comment in MetaTrader

Advanced: Multiple Symbols from One Strategy

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

{
  "pair": "{{ticker}}",
  "direction": "{{strategy.order.action == "buy" ? "LONG" : "SHORT"}}",
  "entry": {{close}}
}

TradingView replaces {{ticker}} with the current chart's symbol automatically.

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 "orderType": "limit" to the payload if you want limit orders (EA must support it)

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 a 5-day Starter trial. No card.

One email now, then occasional tips. Unsubscribe anytime.

Start your free trading journal today

Track every trade, analyze your performance with real data, and build the habits that create consistent profitability.

Get Started Free

No credit card required