pinescript

Solid

Pine Script v6 patterns: syntax rules, performance, debugging, backtesting, visualization. Use when asked to "write a Pine Script", "create an indicator", "build a strategy", "fix Pine code", or mentions PineScript, TradingView, indicator, strategy, or backtest.

Code & Development 31 stars 3 forks Updated 1 weeks ago MIT

Install

View on GitHub

Quality Score: 82/100

Stars 20%
50
Recency 20%
90
Frontmatter 20%
70
Documentation 15%
100
Issue Health 10%
80
License 10%
100
Description 5%
100

Skill Content

# 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 publishi...

Details

Author
iliaal
Repository
iliaal/whetstone
Created
6 months ago
Last Updated
1 weeks ago
Language
Python
License
MIT

Integrates with

Bundled in these plugins

Similar Skills

Semantically similar based on skill content — not just same category