Skip to content
Finance
Skill

/pine-optimizer

Optimizes Pine Script for performance and user experience. Use when improving speed, UI organization, or visual appeal.

From plugin
pinescript
24512 skills3 agents3 commands2 hooks
+1

Claude Code

$ npx -y skills add traderspost/pinescript-agents --skill pine-optimizer --agent claude-code

SKILL.md

pine-optimizer.SKILL.md
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

Pine Script Optimizer

Specialized in enhancing script performance, user experience, and visual presentation on TradingView.

Pine Script v6 2025 Optimization Features

July 2025: Input `active` Parameter - UX Game Changer

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)

September 2025: Plot Line Styles

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)

February 2025: Unlimited Scopes

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 limit

March 2025: Use `for...in` for Collections

The 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
    // process

August 2025: Longer Strings (40,960 chars)

Build 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

⚠️ CRITICAL: UDT-First Code Organization

**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 vs After: Parallel Arrays vs UDT

// ❌ 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)

Performance Gain: xloc.bar_time Eliminates Clamping

// ❌ 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!

UDT Methods for DRY Drawing Code

// ❌ BEFORE: Repeated drawing blocks (~50+ lines each)
// Block for original regression drawing
if show
Read more
@traderspost
Ships withpinescript

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!

24512 skills3 agents1 MCP
Get the whole plugin

Stars on GitHub

Momentum

stars in total
245
Star history of traderspost/pinescript-agents on GitHub, a chart by star-history.com

Other skills on pinescript.

pine-backtester

pine-backtester

Implements comprehensive backtesting and performance metrics. Use when adding trade analysis, equity curves, or statistical…

pine-debugger

pine-debugger

Troubleshoots Pine Script issues and adds debugging capabilities. Use when scripts have errors or unexpected behavior.

pine-developer

pine-developer

Writes production-quality Pine Script v6 code following TradingView guidelines. Use when implementing indicators, strategies, or…

pine-manager

pine-manager

Orchestrates complex Pine Script projects by coordinating multiple development phases. Use for complete trading systems.

pine-publisher

pine-publisher

Prepares Pine Scripts for TradingView publication with documentation and compliance checks. Use when finalizing scripts for…

pine-visualizer

pine-visualizer

Analyzes trading concepts and YouTube videos to extract Pine Script specifications. Use when planning indicators or analyzing…

More skills from other plugins.

ccxt-cli

ccxt-cli

CCXT command-line interface (ccxt-cli) for interacting with 100+ cryptocurrency exchanges directly from the terminal — no code…

ccxt2w45k
@ccxt@ccxtInstall Skill

Questions about pine-optimizer.

Which coding agents can use pine-optimizer?
pine-optimizer installs in Claude Code, Codex, Cursor, Gemini CLI, GitHub Copilot, OpenCode and Windsurf with the skills CLI, using each agent's flag shown on this page. Flowy's auto-invocation, which fires a skill when your prompt matches, runs in Claude Code only.