import x7s0lt1/jsonSignalBuilderV2/1
A utility library for Pine Script that builds structured JSON strings for and external integrations.
✨ Example Use Case
{
"name": "Super Strategy",
"key": "secret123",
"symbol": "BTCUSDT",
"side": "BUY",
"size": 100,
"stop": 29500,
"take": 31000,
"dilution": true,
"public": true,
"flag": ["TEST", "DEBUG"]
}
Using this code in Pine Script:
import x7s0lt1/jsonSignalBuilderV2/1 as json
alert_message = json.object(
json.str("name", "Super Strategy"),
json.str("key", "secret123"),
json.str("symbol", syminfo.ticker),
json.str("side", "BUY"),
json.num("size", 100),
json.num("stop", 29500),
json.num("take", 31000),
json.bool("dilution", true),
json.bool("public", true),
json.raw("flag", '["TEST", "DEBUG"]')
)
alert(alert_message, alert.freq_once_per_bar)
🧩 Library Functions
🔹 str(key, val)
Returns a "key": "value"
string pair.
json.str("name", "Super Strategy")
🔹 num(key, val)
Returns a "key": numericValue
pair.
json.num("size", 100)
🔹 bool(key, val)
Returns a "key": true/false
boolean pair.
json.bool("public", true)
🔹 raw(key, val)
Returns a raw value. Use it for arrays, nested JSON, or preformatted values.
json.raw("flag", '["TEST", "DEBUG"]')
🔹 object(pair1, ..., pair20)
Combines up to 20 preformatted pairs into a valid JSON object.
json.object(json.str("name", "Super Strategy"), ..., json.raw("flag", '["TEST", "DEBUG"]'))
💡 Pro Tips
Always use json.raw
when inserting arrays or nested objects.
You can skip unused slots by simply passing an empty string ""
.
The object()
function returns a full JSON string with braces {}
.
📘 Full Example
import x7s0lt1/jsonSignalBuilderV2/1 as json
alert_message = json.object(
json.str("name", "Super Strategy"),
json.str("key", "secret123"),
json.str("symbol", syminfo.ticker),
json.str("side", "BUY"),
json.num("size", 100),
json.num("stop", 29500),
json.num("take", 31000),
json.bool("dilution", true),
json.bool("public", true),
json.raw("flag", '["TEST", "DEBUG"]')
)
alert(alert_message, alert.freq_once_per_bar)