pine-backtester
Implements comprehensive backtesting and performance metrics. Use when adding trade analysis, equity curves, or statistical…
Optimizes Pine Script for performance and user experience. Use when improving speed, UI organization, or visual appeal.
$ npx -y skills add traderspost/pinescript-agents --skill pine-optimizer --agent claude-codeHow it fires
How this skill gets triggered: by you, by Claude, or both.
/pine-optimizerContext preview
The summary Claude sees to decide when to auto-load this skill.
Optimizes Pine Script for performance and user experience. Use when improving speed, UI organization, or visual appeal.
name: pine-optimizer description: Optimizes Pine Script for performance and user experience. Use when improving speed, UI organization, or visual appeal. allowed-tools: Read, Edit, Grep, Glob
Specialized in enhancing script performance, user experience, and visual presentation on TradingView.
Create conditional input visibility for cleaner UI:
// ✅ BEFORE: All inputs always visible (cluttered)
maType = input.string("EMA", "MA Type", options=["SMA", "EMA", "Custom"])
customLength = input.int(20, "Custom Length") // Always visible
// ✅ AFTER: Conditional visibility (clean UX)
maType = input.string("EMA", "MA Type", options=["SMA", "EMA", "Custom"])
customLength = input.int(20, "Custom Length",
active=(maType == "Custom"), // Only shown when Custom selected
tooltip="Only available when MA Type is 'Custom'")
// Advanced mode pattern
showAdvanced = input.bool(false, "Show Advanced Settings", group="Settings")
advSetting1 = input.int(10, "Advanced 1", group="Advanced", active=showAdvanced)
advSetting2 = input.float(1.5, "Advanced 2", group="Advanced", active=showAdvanced)
advSetting3 = input.bool(true, "Advanced 3", group="Advanced", active=showAdvanced)More visual options without custom drawing:
// Use built-in line styles for cleaner visuals
plot(sma20, "SMA 20", color.blue, linestyle=plot.linestyle_solid)
plot(sma50, "SMA 50", color.red, linestyle=plot.linestyle_dashed)
plot(support, "Support", color.green, linestyle=plot.linestyle_dotted)
// Combine with conditional display
showProjections = input.bool(true, "Show Projections")
plot(showProjections ? projection : na, "Projection",
color.new(color.yellow, 50),
linestyle=plot.linestyle_dotted)No longer limited to 550 scopes - enables more complex, modular code:
// Now possible: deeply nested logic without scope errors
type ComplexType
float value1
float value2
array<float> history
method process(ComplexType this) =>
if this.value1 > 0
if this.value2 > 0
for i = 0 to array.size(this.history) - 1
if array.get(this.history, i) > 0
// Deep nesting now allowed
// Previously would hit 550 scope limitThe preferred and safest way to iterate over collections:
// ✅ BEST: Use for...in for arrays (safest, cleanest)
for element in myArray
// Process element directly - no boundary issues
// ✅ BEST: Use for...in with index when needed
for [index, element] in myArray
// Have both index and value
// ✅ Works with matrices (iterates rows as arrays)
for row in myMatrix
for value in row
// Process each value
// ✅ Works with maps (key-value pairs in insertion order)
for [key, value] in myMap
// Process key-value pair**FALLBACK: Cache boundary if traditional `for` is required:**
// ❌ SLOW/DANGEROUS: Re-evaluates array.size() every iteration
for i = 0 to array.size(arr) - 1
// Can cause infinite loop if array modified
// ✅ FALLBACK: Cache boundary if you need traditional for
arrSize = array.size(arr)
for i = 0 to arrSize - 1
// processBuild more comprehensive info panels:
// Now possible: detailed multi-section reports report = "═══════════════════════════════\n" report += " STRATEGY REPORT \n" report += "═══════════════════════════════\n\n" report += "PERFORMANCE METRICS\n" report += "───────────────────\n" report += "Win Rate: " + str.tostring(winRate, "#.##") + "%\n" report += "Profit Factor: " + str.tostring(pf, "#.##") + "\n" // ... can now include much more detail
**The single biggest optimization you can make is using UDT-first architecture.** This eliminates parallel arrays, simplifies drawing management, and removes bar_index clamping code.
// ❌ BEFORE: 6+ parallel arrays (hard to maintain, error-prone)
var array<float> slopes = array.new<float>()
var array<float> intercepts = array.new<float>()
var array<float> stdDevs = array.new<float>()
var array<int> startBars = array.new<int>()
var array<int> endBars = array.new<int>()
var array<line> centerLines = array.new<line>()
// Must keep ALL arrays in sync - easy to have bugs!
// Push to ALL arrays when adding item
array.push(slopes, newSlope)
array.push(intercepts, newIntercept)
array.push(stdDevs, newStdDev)
array.push(startBars, newStartBar)
array.push(endBars, newEndBar)
// Forgot to push to centerLines? Bug!
// ✅ AFTER: Single UDT array (clean, self-documenting)
type Regression
float slope
float intercept
float stdDev
int startTime // Use TIME, not bar_index!
int endTime
int startBarIndex // Keep for Y calculations
int endBarIndex
line centerLine = na
var array<Regression> regressions = array.new<Regression>()
// One push, all data together
newReg = Regression.new(slope=newSlope, intercept=newIntercept, ...)
array.push(regressions, newReg)// ❌ BEFORE: Clamping code everywhere (slow, complex)
leftBar = math.max(0, bar_index - startOffset) // Clamp to valid range
if bar_index - startBar > 5000
leftBar := bar_index - 5000 // Historical buffer limit!
line.set_x1(myLine, leftBar)
// ✅ AFTER: xloc.bar_time has NO limit - just draw!
line.new(startTime, y1, endTime, y2, xloc=xloc.bar_time)
// No clamping needed! Works for ANY historical bar!// ❌ BEFORE: Repeated drawing blocks (~50+ lines each) // Block for original regression drawing if show
A comprehensive Pine Script development environment powered by Claude Code's Skills system. This tool helps you create professional TradingView indicators and strategies with AI assistance. Just type start to begin!
Implements comprehensive backtesting and performance metrics. Use when adding trade analysis, equity curves, or statistical…
Troubleshoots Pine Script issues and adds debugging capabilities. Use when scripts have errors or unexpected behavior.
Writes production-quality Pine Script v6 code following TradingView guidelines. Use when implementing indicators, strategies, or…
Orchestrates complex Pine Script projects by coordinating multiple development phases. Use for complete trading systems.
Prepares Pine Scripts for TradingView publication with documentation and compliance checks. Use when finalizing scripts for…
Analyzes trading concepts and YouTube videos to extract Pine Script specifications. Use when planning indicators or analyzing…