PINE LIBRARY
JsonAlert

JsonAlert Library – Convert TradingView Alerts to JSON for Server Processing! 📡
🚀 The JsonAlert library makes it easy to send TradingView alerts as structured JSON to your server, allowing seamless integration with automated trading systems, databases, or webhook-based services.
📌 Features:
✅ Converts TradingView alert data into JSON format
✅ Supports custom key-value pairs for flexibility
✅ Allows frequency control (once per bar, once per bar close, every update)
✅ Easy to integrate with server-side PHP or other languages
Note that you have to pass one string array for keys and one string array for values , also you should pass alert frequency .
📖 Example Usage in Pine Script:
📡 Json Output Example:
🖥️ Server-Side PHP Example:
There you can integrate JsonAlert with your server in seconds! :)
🚀 The JsonAlert library makes it easy to send TradingView alerts as structured JSON to your server, allowing seamless integration with automated trading systems, databases, or webhook-based services.
📌 Features:
✅ Converts TradingView alert data into JSON format
✅ Supports custom key-value pairs for flexibility
✅ Allows frequency control (once per bar, once per bar close, every update)
✅ Easy to integrate with server-side PHP or other languages
Note that you have to pass one string array for keys and one string array for values , also you should pass alert frequency .
📖 Example Usage in Pine Script:
Pine Script®
//@version=6
indicator("My script" , overlay = true)
import Penhan/JsonAlert/1 as alrt
if high > low
var array<string> keys = array.from("ticker", "timeframe", "pattern")
var array<string> values = array.from( syminfo.ticker , timeframe.period , str.tostring(123.45) )
alrt.alarm (keys, values , alert.freq_once_per_bar)
indicator("My script" , overlay = true)
import Penhan/JsonAlert/1 as alrt
if high > low
var array<string> keys = array.from("ticker", "timeframe", "pattern")
var array<string> values = array.from( syminfo.ticker , timeframe.period , str.tostring(123.45) )
alrt.alarm (keys, values , alert.freq_once_per_bar)
📡 Json Output Example:
Pine Script®
{"ticker": "BTCUSDT","timeframe": "1","pattern": "123.45"}
🖥️ Server-Side PHP Example:
Pine Script®
<?php
update = file_get_contents("php://input");
logFile = 'requests_log.txt';
file_put_contents(logFile, update . "\n", FILE_APPEND | LOCK_EX);
?>
update = file_get_contents("php://input");
logFile = 'requests_log.txt';
file_put_contents(logFile, update . "\n", FILE_APPEND | LOCK_EX);
?>
There you can integrate JsonAlert with your server in seconds! :)
Biblioteca do Pine
No verdadeiro espirito do TradingView, o autor desse código Pine o publicou como uma biblioteca de código aberto, para que outros programadores Pine da nossa comunidade possam reusa-los. Parabéns ao autor! Você pode usar essa biblioteca privadamente ou em outras publicações de código aberto, mas a reutilização desse código em publicações é regida pelas Regras da Casa.
Penhan AKA JavadIsHere
Aviso legal
As informações e publicações não devem ser e não constituem conselhos ou recomendações financeiras, de investimento, de negociação ou de qualquer outro tipo, fornecidas ou endossadas pela TradingView. Leia mais em Termos de uso.
Biblioteca do Pine
No verdadeiro espirito do TradingView, o autor desse código Pine o publicou como uma biblioteca de código aberto, para que outros programadores Pine da nossa comunidade possam reusa-los. Parabéns ao autor! Você pode usar essa biblioteca privadamente ou em outras publicações de código aberto, mas a reutilização desse código em publicações é regida pelas Regras da Casa.
Penhan AKA JavadIsHere
Aviso legal
As informações e publicações não devem ser e não constituem conselhos ou recomendações financeiras, de investimento, de negociação ou de qualquer outro tipo, fornecidas ou endossadas pela TradingView. Leia mais em Termos de uso.