Validate the rendered message
Do not validate only the template. Trigger a test alert and inspect the message received after placeholders or dynamic values are resolved.
Pine Script alert guide
A stock trading signals JSON format should be predictable for the system that receives it. Start with a small schema, keep text in double quotes, send numbers as numbers, and validate the exact payload before connecting it to any automated workflow.
This example carries the minimum context most receivers need. Add keys only when the endpoint has a documented use for them. A JSON alert is a message contract, not an order by itself.
{
"symbol": "{{ticker}}",
"action": "buy",
"price": {{close}},
"timeframe": "{{interval}}",
"signal_id": "ema_cross_up"
}The alert() function accepts a dynamic series string. This sample waits for a confirmed bar, converts the price to text for string assembly, and leaves the resulting JSON price unquoted so the receiver gets a number.
//@version=6
indicator("EMA signal JSON", overlay = true)
fastEma = ta.ema(close, 9)
slowEma = ta.ema(close, 21)
longSignal = ta.crossover(fastEma, slowEma)
plot(fastEma, color = color.blue)
plot(slowEma, color = color.orange)
if longSignal and barstate.isconfirmed
payload = '{"symbol":"' + syminfo.ticker +
'","action":"buy","price":' +
str.tostring(close, format.mintick) +
',"timeframe":"' + timeframe.period +
'","signal_id":"ema_cross_up"}'
alert(payload, alert.freq_once_per_bar_close)Do not validate only the template. Trigger a test alert and inspect the message received after placeholders or dynamic values are resolved.
TradingView warns against putting passwords or login credentials in the webhook body. Authenticate and authorize at the receiver.
Use a signal identifier and receiver-side deduplication so a retry does not create an unintended duplicate action.
Treat Pine Script as the signal source. The receiver remains responsible for schema checks, limits, logging, and any execution decision.
Sources checked August 7, 2026.