ia-pinescript
by @iliaal
Pine Script v6: syntax, performance, error diagnosis, backtesting, visualization. Use when writing or debugging `.pine` files or TradingView Pine indicators/...
clawhub install compound-eng-pinescriptπ About This Skill
name: ia-pinescript class: language description: >- Pine Script v6: syntax, performance, error diagnosis, backtesting, visualization. Use when writing or debugging
.pine files or TradingView
Pine indicators/strategies.
paths: "**/*.pine"
Pine Script Development
Verify before implementing: For Pine Script version-specific syntax or new built-in functions, search current docs via search_docs before writing code. TradingView updates Pine Script frequently and training data may be stale.
Critical Syntax Rules
isBull = close > open
barColor = isBull ? color.green : color.red
plot(condition ? value : na)Platform Limits
500 bars history for request.security() | 500 plot calls | 64 drawing objects | 40 request.security() calls | 100KB compiled size
Performance
request.security() returning [close, high, low] instead of 3 separate callsarray.new(size) instead of push-and-resizeDebugging
TradingView has no console or debugger. Use these patterns:
label.new(bar_index, high, str.tostring(myVar)) to inspect valuestable.new() with barstate.islast for real-time variable dashboardif input.bool("Debug", false) -- remove before publishingpreviousValue = value[1], flag when historical values changeStrategy & Backtesting
strategy.* functions: strategy.wintrades, strategy.losstrades, strategy.grossprofitmaxEquity = math.max(strategy.equity, nz(maxEquity[1])), then dd = (maxEquity - strategy.equity) / maxEquity * 100dailyReturn * 252 / (stdDev * math.sqrt(252))close[lookforward] to measure prediction accuracy, track true/false positive ratesVisualization
color.from_gradient() for trend strength coloringsize.small for intraday, size.normal for daily+Publishing
indicator()/strategy()@version, @description, @param tagstooltip="Line 1" + "\n" + "Line 2"Common Coding Mistakes
input() with sensible defaults.barstate.isconfirmed guard -- calculations on unconfirmed bars cause repainting. Always guard entry signals.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
barstate.isconfirmed guard present where needed