pinescriptlisted
Install: claude install-skill iliaal/whetstone
# 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