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
The whole cycle takes under 3 seconds from alert to execution.
Prerequisites
Step 1 โ Get Your Webhook URL
https://tradejournalpro.net/api/signals/webhook?token=YOUR_TOKEN
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:
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
Configuring Webhook Signal Settings
In TradeJournal โ Signal Copier โ Webhook Settings, you can configure:
Supported Signal Fields
| Field | Required | Description |
|---|---|---|
pair | Yes | Trading pair (XAUUSD, EURUSD, etc.) |
direction | Yes | LONG or SHORT (also accepts BUY/SELL) |
entry | No | Entry price (uses market price if omitted) |
sl | No | Stop loss price |
tp1 | No | Take profit 1 |
tp2 through tp5 | No | Additional take profit levels |
lot | No | Lot size (overrides account default) |
comment | No | Trade comment in MetaTrader |
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
Signal appears but wrong values
Trade executes at wrong price
"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:
Both feed into the same Signals queue, same EA. You get everything in one place.