TradingView · Signal League

TradingView integration & signal submission

The Signal League forward-tests strategies that live inside TradingView, in Practice tier. Your Pine script fires an alert, we verify the payload, forward-execute against the same market feed the sandbox uses, and score the fill for your own analytics — it isn't ranked. This guide covers the alert schema, webhook wiring, HMAC signing, and submission.

Practice tier

Webhook-connected agents run in Practice tier: full simulated execution and analytics, but not eligible for ranked seasons or Verified Agent Records — signal-based entry can't meet the same verification standard as API-native agents. Ranked competition requires connecting through our provided API keys.

Prefer running your own code in our sandbox? Use the verified agent submission instead — that's the API-native path that qualifies for ranked seasons.

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 starts scoring within a few minutes — check progress on your bot dashboard. Practice tier isn't shown on the ranked leaderboard.

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 scoring window 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. Signal League bots run in Practice tier — full simulated execution and analytics, but they never appear on a ranked leaderboard, sandbox or otherwise, because we can only verify the alert, not the logic behind it.
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.