TradingView · Signal League

TradingView integration & signal submission

The Signal League ranks strategies that live inside TradingView. Your Pine script fires an alert, we verify the payload, forward-execute against the same market feed the sandbox uses, and score the fill. This guide covers the alert schema, webhook wiring, HMAC signing, and submission.

Prefer running your own code in our sandbox? Use the verified bot submission instead — it ranks higher on the combined leaderboard.

1 · Register a bot

Go to /submit, create a bot of kind signal, and copy the two values shown once:

  • bot_id — goes in every alert body.
  • SS_WEBHOOK_SECRET — used only to sign; never send it.

2 · Alert payload schema

The alert "Message" box must contain valid JSON matching this schema. TradingView placeholders like {{close}} and {{timenow}} are substituted at fire time.

{
  "bot_id": "ss_bot_9f2a...",         // issued when you register on /submit
  "strategy": "mean_revert_v3",        // your own label, <= 64 chars
  "market": "polymarket:0xabc...",     // canonical market id from /leaderboard/methodology
  "side": "buy",                       // "buy" | "sell" | "close"
  "size_pct": 5,                       // % of allocated bankroll, 0.1 - 100
  "price_hint": 0.42,                  // optional limit price (0..1 for event contracts)
  "ts": "{{timenow}}",                 // TradingView placeholder, ISO-8601 UTC
  "nonce": "{{timestamp}}-{{ticker}}", // must be unique per alert
  "sig": "<hmac_sha256>"               // hex digest, see 'Signing' below
}

3 · Pine script skeleton

Drop this into a fresh strategy, tune the entries, and paste the JSON block (from step 2) into the alert dialog's "Message" field.

//@version=5
strategy("SS Mean Revert v3", overlay=true)

// ---- entries -----------------------------------------------------------
longCond  = ta.crossover(close, ta.sma(close, 20))
shortCond = ta.crossunder(close, ta.sma(close, 20))

if longCond
    strategy.entry("L", strategy.long)
if shortCond
    strategy.entry("S", strategy.short)

// ---- alert payload (paste into the alert "Message" box) ---------------
// {
//   "bot_id": "ss_bot_9f2a...",
//   "strategy": "mean_revert_v3",
//   "market": "polymarket:0xabc...",
//   "side": "{{strategy.order.action}}",
//   "size_pct": 5,
//   "price_hint": {{close}},
//   "ts": "{{timenow}}",
//   "nonce": "{{timestamp}}-{{ticker}}",
//   "sig": "REPLACE_WITH_HMAC"
// }

4 · Webhook URL

In the TradingView alert dialog, enable "Webhook URL" and paste:

https://www.scriptsamur.ai/api/public/tradingview

The endpoint is public but requires a valid HMAC. Unsigned or replayed payloads return 401.

5 · Signing (HMAC-SHA256)

TradingView can't compute HMACs at fire time, so you have two options:

  1. Pre-sign the exact JSON body once and hardcode the sig field. Works for static alerts; breaks if any placeholder changes.
  2. Route the alert through a tiny relay (Cloudflare Worker, Fly machine, even a Vercel function) that adds the X-SS-Signature header before forwarding to us. Recommended.

Reference signer:

import hmac, hashlib, json, os

secret = os.environ["SS_WEBHOOK_SECRET"].encode()  # shown once on /submit
body   = open("alert.json", "rb").read()
sig    = hmac.new(secret, body, hashlib.sha256).hexdigest()
print(sig)  # paste as the "sig" field, or send via X-SS-Signature header

Test with curl:

curl -X POST https://www.scriptsamur.ai/api/public/tradingview \
  -H "Content-Type: application/json" \
  -H "X-SS-Signature: $SIG" \
  --data @alert.json

6 · Submit for the season

  1. Fire at least 3 test alerts on the current season's paper markets.
  2. Open /my-bots, confirm your bot shows signal_ok, and click Enter season.
  3. Your bot appears on the Signal League tier within a few minutes.

Anti-abuse rules

  • · One bot_id per strategy — no round-robin submissions.
  • · Max 1 alert per market per 5 seconds; bursts are dropped, not queued.
  • · Alert ts must be within ±30s of server time.
  • · Editing a Pine script mid-season resets your rank to the new deploy time.
  • · Signals that consistently front-run a shared indicator get soft-flagged for review.

FAQ

Does the Signal League count toward the verified sandbox leaderboard?
No. Signals live on their own tier because the code doesn't run in our sandbox — we can only verify the alert, not the logic. Verified sandbox bots always rank above signal-only bots on the combined board.
What happens if two alerts arrive with the same nonce?
The second one is rejected. Nonces are required and must be unique per bot per season. This prevents replay attacks and double-fills.
Can I edit an alert after it fires?
No. Once an alert reaches the webhook it's locked into the run log. Cancel by sending a 'close' side for the same market.
What disqualifies a signal run?
Missing or invalid HMAC, unsupported market id, size_pct outside 0.1–100, more than 1 alert per market per 5s, or any alert timestamp more than 30s off from server time.