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! :)
Pine library
In true TradingView spirit, the author has published this Pine code as an open-source library so that other Pine programmers from our community can reuse it. Cheers to the author! You may use this library privately or in other open-source publications, but reuse of this code in publications is governed by House Rules.
Penhan AKA JavadIsHere
Disclaimer
The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.
Pine library
In true TradingView spirit, the author has published this Pine code as an open-source library so that other Pine programmers from our community can reuse it. Cheers to the author! You may use this library privately or in other open-source publications, but reuse of this code in publications is governed by House Rules.
Penhan AKA JavadIsHere
Disclaimer
The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.