
Ia Pinescript
- 3 installs
- 28 repo stars
- Updated August 5, 2026
- iliaal/whetstone
Guides Pine Script v6 development for TradingView: syntax rules, platform limits, performance, error diagnosis, and backtesting.
About
A skill covering Pine Script v6 syntax, TradingView platform limits, performance patterns, and debugging without a console. A developer uses it when writing or debugging .pine files or TradingView indicators and strategies.
- Critical syntax rules (one-line ternaries, no plot() in local scopes)
- Platform limits and tuple security-call performance patterns
Ia Pinescript by the numbers
- 3 all-time installs (skills.sh)
- Ranked #847 of 1,106 Finance & Trading skills by installs in the Skillselion catalog
- Data as of Aug 5, 2026 (Skillselion catalog sync)
npx skills add https://github.com/iliaal/whetstone --skill ia-pinescriptAdd your badge
Show developers this skill is listed on Skillselion. Paste this into your README.
| Installs | 3 |
|---|---|
| repo stars | ★ 28 |
| Last updated | August 5, 2026 |
| Repository | iliaal/whetstone ↗ |
What it does
Guides Pine Script v6 development for TradingView: syntax rules, platform limits, performance, error diagnosis, and backtesting.
Files
Pine Script Development
Verify before implementing: For Pine Script version-specific syntax or new built-in functions, look up current docs via Context7 (query-docs) before writing code. TradingView updates Pine Script frequently and training data may be stale.
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()withbarstate.islastfor 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])), thendd = (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.smallfor intraday,size.normalfor 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,@paramtags - 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
Common Coding Mistakes
- Indicator stacking (RSI + Stochastics + CCI) -- all measure the same thing (momentum). Use indicators from different categories instead.
- Overfitting parameters: if optimal values are oddly specific (RSI 23 instead of 20), the backtest is curve-fitted. Use round numbers and
input()with sensible defaults. - Missing
barstate.isconfirmedguard -- calculations on unconfirmed bars cause repainting. Always guard entry signals. - Hardcoded thresholds without
input()-- makes the script untestable across instruments.
Workflow
1. Write indicator/strategy in Pine Editor 2. Test with bar replay and strategy tester on multiple timeframes 3. Walk-forward validate before trusting backtest results (see Strategy & Backtesting above) 4. Verify: run on 3+ symbols and 2+ timeframes
Verify
- Indicator compiles without errors on TradingView
- No repainting:
barstate.isconfirmedguard present where needed - Walk-forward tested on 3+ symbols across different timeframes
ia-pinescript findings log
Persistent iteration evidence for ia-pinescript. See the /diagnose-negatives workflow Step 3 for the schema.
EX-001: Misfire on TradingView MCP server (JS) audit
- Label: negative
- Kind: wrong_trigger
- Origin: human-verified (diagnose-negatives reviewer accepted)
- Source: 2 of 2 negative sessions in distillery/.eval-data/ia-pinescript/sessions.jsonl (2026-04-27 harvest)
- Status: resolved
- Expected behavior: skill should not inject when the user is auditing a JavaScript MCP server that connects to the TradingView API but contains zero
.pinefiles - Observed behavior: skill injected because regex
tradingview|...matched bare "tradingview" in the prompt; agent then loaded ia-simplifying-code and ia-code-review (correct skills), wasting the injection - Skill delta:
plugins/whetstone/hooks/skill-patterns.sh:65: tightened regex so baretradingviewno longer matches; required Pine-context qualifier within 30 chars (tradingview.{0,30}(pine|indicator|strategy|chart|script)); added symmetric\bstrategy\b.{0,20}(pine|trading.?view)clauseplugins/whetstone/skills/ia-pinescript/SKILL.md:4-7: rewrote description to scope triggers to.pinefiles or TradingView Pine indicators/strategies (drops standalone "TradingView", "indicators", "strategies", "backtesting" as triggers)distillery/tests/fixtures/triggers/ia-pinescript.jsonl: added two negative-case fixtures from the actual misfire prompts- Anonymization: redacted nothing; both prompts were generic infrastructure audits with no sensitive content
ia-pinescript Specification
Intent
ia-pinescript is a language-class skill (stack-specific patterns and idioms). Pine Script v6 patterns: syntax, performance, error diagnosis, backtesting, visualization. Use when working with PineScript, TradingView, indicators, strategies, or backtesting.
Scope
In scope:
- Behaviors described in
SKILL.mdand routed via the should_trigger phrasings indistillery/tests/fixtures/triggers/ia-pinescript.jsonl. - Updates to runtime behavior, structure, trigger precision, references, and validation.
Out of scope:
- Acting as the runtime instructions themselves (those live in
SKILL.md). - Trigger phrasings already covered by adjacent
ia-*skills (validate-pluginflags >70% description overlap as DUPLICATE_TRIGGER). - <!-- to fill in: domain-specific exclusions when the skill drifts -->
Trigger Context
- Class:
language - Hook regex:
plugins/whetstone/hooks/skill-patterns.sh->SKILL_PATTERNS[ia-pinescript] - Common requests (from fixture should_trigger):
- "write a pine script indicator for RSI divergence"
- "fix the TradingView strategy backtest results"
- "write a Pine Script v6 indicator for ATR-based stops"
- Should not trigger for (from fixture should_not_trigger):
- "set up a PostgreSQL replication cluster"
- "write unit tests for the checkout service"
- "write a Python pandas script to backtest"
Source And Evidence Model
Authoritative sources:
SKILL.md-- runtime instructions and reference routing.references/*.md-- bundled supplementary content (0 file(s)).distillery/tests/fixtures/triggers/ia-pinescript.jsonl-- positive and negative trigger phrasings under regression test.plugins/whetstone/hooks/skill-patterns.sh-- regex pattern that fires this skill.distillery/.eval-data/ia-pinescript/-- harvested session examples (when present).
Data that must not be stored in this skill or its references:
- Secrets, credentials, tokens.
- Machine-specific filesystem paths (
/home/...,/Users/...,~/ai/...). The validator (MACHINE_PATH_LEAK) flags these as HIGH. - Private URLs, customer data, or unredacted personal information.
Coverage matrix
| Dimension | Status | Evidence |
|---|---|---|
| Trigger fixtures | complete | distillery/tests/fixtures/triggers/ia-pinescript.jsonl (>=5 should_trigger, >=5 should_not_trigger) |
| Hook regex pattern | complete | plugins/whetstone/hooks/skill-patterns.sh (SKILL_PATTERNS[ia-pinescript]) |
| Reference architecture | n/a | no references; SKILL.md is self-contained |
| Real-usage signal | <!-- populated by harvest-sessions when sessions exist --> | distillery/.eval-data/ia-pinescript/ (created by harvest-sessions) |
Evaluation
Lightweight (run on every change):
python3 distillery/scripts/distiller.py validate-plugin --component ia-pinescript
python3 distillery/scripts/distiller.py test-triggers --skill ia-pinescriptDeeper (when behavior risk warrants):
python3 distillery/scripts/distiller.py dspy-eval ia-pinescript
python3 distillery/scripts/distiller.py diagnose-negatives ia-pinescriptAcceptance gates:
validate-plugin --component ia-pinescriptreturns 0 HIGH findings.test-triggers --skill ia-pinescriptreturns F1 = 1.0 with floors of 5 should_trigger and 5 should_not_trigger.- For dspy-eval, the composite score does not regress against the most recent saved baseline (see
distillery/.eval-data/ia-pinescript/history.json).
Known Limitations
<!-- to fill in over time as drift surfaces. Default rule: any time diagnose-negatives surfaces a recurring failure pattern, document it here so future maintainers understand the trade-off the current implementation accepts. -->
Maintenance Notes
- Update
SKILL.mdwhen the runtime workflow, branch conditions, or output contract changes. - Update this
SPEC.mdwhen intent, scope, evidence model, evaluation gates, or maintenance expectations change. - Update the trigger fixture when adding new positive phrasings, removing stale ones, or expanding scope (the 5/5 floor is a hard validator gate).
- Update the hook regex in
skill-patterns.shwhenever fixture positives expose a missed phrasing; verify F1 = 1.0 witheval-triggersbefore committing. - Run the full release pipeline via
/release-- never bump versions or update CHANGELOG.md from a per-skill edit.