pinescript

A reference guide for Pine Script version 6, the programming language used to create TradingView indicators and trading strategies.

In plain words
What is it for?
Use it to build indicators or strategies, fix Pine code, improve script performance, and reduce errors such as repainting or invalid plotting.
Why use it?
It helps avoid common language errors and work within TradingView's limits when writing, debugging, visualizing, or backtesting scripts.

Skill for Claude CodeCodex

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add skills/iliaal/whetstone/pinescript
Any agent
npx skills add iliaal/whetstone --skill pinescript
Clone the repo
git clone --depth 1 https://github.com/iliaal/whetstone

Made for: Claude Code, Codex.

Per session 64 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 912 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00064 $0.00912
Opus 5 $0.00032 $0.00456
Sonnet 5 $0.00013 $0.00182
Haiku 4.5 $0.00006 $0.00091

Measured 2d ago against content hash ac71ebe96884, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

pinescript scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 2d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

distillery/generated-skills/pinescript/SKILL.md · 71 lines

How it starts

The opening of the file, as written. The whole thing — 71 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Pine Script Development

Critical Syntax Rules

  • Ternary operators MUST stay on one line — splitting across lines causes "end of line without line continuation" error. For complex ternaries, use intermediate variables:
    isBull = close > open
    barColor = isBull ? color.green : color.red
    
  • Continuation lines MUST be indented MORE than the starting line — same indentation = error
  • NEVER use plot() inside local scopes (if/for/functions) — use conditional value instead: plot(condition ? value : na)
  • barstate.isconfirmed — use to prevent repainting on real-time bars

Platform Limits

500 bars history for request.security() | 500 plot calls | 64 drawing objects | 40 request.security() calls | 100KB compiled size

Performance

  • Tuple security calls — one request.security() returning [close, high, low] instead of 3 separate calls
  • Pre-allocate arrays with array.new<type>(size) instead of push-and-resize
  • Short-circuit signals: build conditions incrementally, exit early when first condition fails
  • Cache repeated calculations in variables — Pine recalculates every bar

Debugging

TradingView has no console or debugger. Use these patterns:

  • Label debugging: label.new(bar_index, high, str.tostring(myVar)) to inspect values
  • Table monitor: table.new() with barstate.islast for real-time variable dashboard
  • Debug mode toggle: wrap all debug code in if input.bool("Debug", false) — remove before publishing
  • Repainting detector: track previousValue = value[1], flag when historical values change

Strategy & Backtesting

  • Use strategy.* functions: strategy.wintrades, strategy.losstrades, strategy.grossprofit
  • Drawdown tracking: maxEquity = math.max(strategy.equity, nz(maxEquity[1])), then dd = (maxEquity - strategy.equity) / maxEquity * 100
  • Sharpe: dailyReturn * 252 / (stdDev * math.sqrt(252))
  • Walk-forward validation — optimize on period 1, test on period 2, re-optimize on period 2, test on period 3. If metrics degrade > 30%, parameters are overfit.
  • Indicator accuracy testing — use forward-looking close[lookforward] to measure prediction accuracy, track true/false positive rates

Read the full file on GitHub · 71 lines

Files

What ships with it

1 file beside SKILL.md in the same directory: the scripts, references and assets a skill reads on demand. Not counted in the per-session cost; read them before you install if any of them is executable.

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 2d ago First seen · 71 lines · 64 tokens per session scan A ac71ebe96884

Subscribe to this mod's changes

pinescript is a skill published in the GitHub repository iliaal/whetstone (32 stars, last pushed 3d ago), licensed MIT. It adds 64 tokens to every session and 912 once invoked, about $0.0003 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.

Related

Other skills, from other repositories

x402

Set up Browser Use Cloud payments with x402 — pay per request from a crypto wallet (USDC on Base mainnet), no signup or API key. Two setups it works out up front — "just use it" (set up a wallet so you or Claude Code can run cloud browser tasks paid from the wallet — Claude writes and runs throwaway scripts, nothing…

browser-use/browser-use · 175 tokens

omh-finance-analysis

This is a Hermes-native finance-analysis workflow skill.

rlaope/oh-my-hermes · 60 tokens

pinme-uniwebpay

Use when generating, modifying, or reviewing PinMe Worker (Cloudflare Worker TypeScript) code that accepts payments through UniwebPay — payment links, products/prices, checkout sessions, payment status reads, refunds, subscriptions, or handling UniwebPay webhooks with @uniwebpay/sdk in a PinMe project.

glitternetwork/pinme · 71 tokens

financial-expert

Use when users need China or Hong Kong securities, funds, fund managers, company financials, valuation, global macro or industry time series, broker research, announcements, financial news, or enterprise-risk data. Triggers include 选股、基金筛选、基金经理、净利润、营收、ROE、估值、 GDP、CPI、核心 PCE、行业产销价、研报、公告、财经新闻、工商与司法风险。.

modelstudioai/skills · 98 tokens

comps-valuation-analyst

Use when valuing a public company with peer multiples, building comparable-company tables, or pressure-testing a valuation range with EV/EBITDA, P/E, and EV/Sales.

seaworld008/Commonly-used-high-value-skills · 45 tokens

billing-automation

Build automated billing systems for recurring payments, invoicing, subscription lifecycle, and dunning management. Use when implementing subscription billing, automating invoicing, or managing recurring payment systems.

seaworld008/Commonly-used-high-value-skills · 40 tokens