TradingView Pine v5 example and recommended webhook payload for automation pipelines (include a secret in the alert).
Pine Script
Category: Code Library • Tags: pine, tradingview, webhook • Published: PUBLISH_DATE
Pine v5 example
Copy// @version=5
indicator("Simple Alert Example", overlay=true)
sma = ta.sma(close, 20)
plot(sma, color=color.orange)
if ta.crossover(close, sma)
alert('{"action":"BUY","symbol":"' + syminfo.ticker + '","price":' + str.tostring(close) + ',"secret":"YOUR_SECRET"}', alert.freq_once_per_bar)
Suggested webhook JSON
{
"action": "BUY",
"symbol": "BTCUSD",
"price": 62400.5,
"time": "2025-01-10T12:00:00Z",
"secret": "your-obfuscated-secret"
}
- Include a secret in the alert payload and verify server-side using HMAC or token compare.
- Respond 200 quickly and enqueue heavy work (orders, DB writes) in background workers.
License: MIT
