pinescript
/pinescript
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.
- Author
- iliaal ↗
- Repository
- whetstone ↗
- Licence
- MIT
- Last repository change
- 26.10.2026
Assessment and security
- Files in this package
- 2
- Scripts
- 0
- HTML comments
- 0
- URLs in SKILL.md
- 0
No signals detected. Repository changed on 26.10.2026, without references to retired models or APIs.
MIT, open: use and modify while retaining author attribution.
What it does and when to use it
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.
Triggers from the description
Original author description
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.
How it works
- Critical Syntax Rules
- Platform Limits
- Performance
- Debugging
- Strategy & Backtesting
- Visualization
- Publishing
- Anti-Patterns
SKILL.md preview
---
name: pinescript
description: >-
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.
---
# 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
## Visualization
- `color.from_gradient()` for trend strength coloring
- Adaptive text sizing: `size.small` for intraday, `size.normal` for daily+
- Dynamic table rows — resize based on enabled features via input toggles
- Professional color constants: define BULL_COLOR, BEAR_COLOR, NEUTRAL_COLOR once with transparency
## Publishing
- Documentation goes at TOP of .pine file as comments before `indicator()`/`strategy()`
- Use `@version`, `@description`, `@param` tags
- Multi-line tooltips: `tooltip="Line 1" + "\n" + "Line 2"`
- **TradingView House Rules**: no financial advice, no performance guarantees, no external links, no obfuscated code, no donation requests
## Anti-Patterns
- Indicator stacking (RSI + Stochastics + CCI) — all measure the same thing (momentum). Use indicators from different categories instead.
- Trading divergence without structure confirmation — wait for break above prior swing high before entry, divergence alone can persist far longer than expected
- Overfitting signals: if optimal parameters are oddly specific (RSI 23 instead of 20), the backtest is curve-fitted. Use round numbers.
- Treating support/resistance as exact prices — they are zones (crypto 1-3%, forex 20-50 pips)
Files in this package (2)
- SKILL.md 4 KB
- manifest.json 1 KB
Versions
| Repository | Score | Licence |
|---|---|---|
| This page · iliaal/whetstone | 100 | MIT |
| iliaal/ai-skills | 100 | MIT |
Database snapshot: 13.11.2026 · package version 34279ab835bb (SHA-256 digest of the entire package)
Downloads in the last 30 days: 0 · ranking
Report a problem with this skill: harmful content, incorrect descriptions or an author’s removal request.
Similar skills
- 100pinescript-v6
Write and debug TradingView Pine Script v6 correctly. Covers the execution model, the v6 type system, overloaded drawing constructors, anti-repainting with request.security, and the API TradingView shipped through 2026. Validate every script before claiming it works. Use when… - 100pinescript-indicator
Generate working TradingView Pine Script v6 indicators — plotting, drawing objects, tables, alerts, inputs and the plot/object limits that break scripts at scale. Provides validated scaffolds to start from rather than composing from memory. Use when asked to write, create or… - 100mph-pine
Build TradingView Pine Script v6 indicators in Michael's house style. Synthwave dashboard, faithful math, v6-compliant, no em dashes. Triggers on "pine script", "tradingview indicator", "write a pine indicator", "/mph-pine". - 100mph-pine
Build TradingView Pine Script v6 indicators in Michael's house style. Synthwave dashboard, faithful math, v6-compliant, no em dashes. Triggers on "pine script", "tradingview indicator", "write a pine indicator", "/mph-pine". - 95pinescript-core
Use when writing or reading Pine Script language fundamentals — @version, script types (indicator/strategy/library), type system (series/simple/const), var/varip/input.*, control flow, user-defined functions/types, gotchas (repainting, na handling, max_bars_back). - 100translate
Converts a strategy document into lookahead-free backtest code in Python and TradingView Pine Script v6. Use when the user wants a strategy coded, backtested, or turned into a TradingView indicator or strategy.