Skip to content
Finance
Skill

/pine-debugger

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

From plugin
pinescript
24212 skills3 agents3 commands2 hooks
+1

Claude Code

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

SKILL.md

pine-debugger.SKILL.md
name: pine-debugger
description: Troubleshoots Pine Script issues and adds debugging capabilities. Use when scripts have errors or unexpected behavior.
allowed-tools: Read, Edit, Grep, Glob

Pine Script Debugger

Specialized in adding debugging tools and troubleshooting Pine Script code in TradingView's often opaque environment.

⚠️ Pine Script v6 2025 Common Pitfalls

CRITICAL: March 2025 Breaking Change - For Loop Boundaries

`for` loops now re-evaluate boundaries **every iteration**.

**PREFERRED FIX: Use `for...in` loops:**

// ✅ BEST: Use for...in for arrays (safe and clean)
for element in myArray
    // Process element - safe even if array is modified

// ✅ BEST: Use for...in with index when needed
for [index, element] in myArray
    // Have both index and value

// ✅ for...in works with matrices too
for row in myMatrix
    // row is an array of the current row's values

// ✅ for...in works with maps (key-value pairs)
for [key, value] in myMap
    // Iterate in insertion order

**FALLBACK: Cache boundary if traditional `for` is required:**

// ❌ BUG: Infinite loop or unexpected behavior
var arr = array.new<int>()
for i = 0 to array.size(arr)  // Re-evaluated each iteration!
    array.push(arr, i)        // Array grows, loop never ends

// ✅ FALLBACK: Cache the boundary before the loop
arrSize = array.size(arr)
for i = 0 to arrSize
    array.push(arr, i)

**Debug check:** If a loop seems to hang, either switch to `for...in` or verify boundaries are cached.

Line Continuation Errors

The most common syntax error. Updated rules as of December 2025:

// ❌ ERROR: "end of line without line continuation"
text = condition ?
    "value1" :
    "value2"

// ✅ FIX: Keep ternary on one line
text = condition ? "value1" : "value2"

// ✅ Inside parentheses - any indentation now works (Dec 2025)
plot(series,
    title="Plot",
    color=color.blue)

// ⚠️ Outside parentheses - still requires non-multiple-of-4 indentation
condition = value1 > value2 and
     value3 > value4   // Must use odd indentation (e.g., 5 spaces)

Bid/Ask Variables Return NA

// ❌ UNEXPECTED: Always na on most charts
bidValue = bid  // Only works on 1T (tick) timeframe!

// ✅ DEBUG: Check timeframe
if barstate.islast
    label.new(bar_index, high,
        "Bid: " + (na(bid) ? "N/A (not 1T)" : str.tostring(bid)))

Plot in Local Scope

// ❌ ERROR: "Cannot use 'plot' in local scope"
if condition
    plot(value)

for i = 0 to 10
    plot(close[i])

// ✅ FIX: Use conditional plotting at global scope
plot(condition ? value : na)

Core Debugging Toolkit

1. Label-Based Value Inspector

// Debug label showing multiple values
if barstate.islast
    debugText = "RSI: " + str.tostring(rsiValue, "#.##") + "\n"
    debugText += "MA: " + str.tostring(maValue, "#.##") + "\n"
    debugText += "Signal: " + (buySignal ? "BUY" : "NEUTRAL")
    label.new(bar_index, high * 1.05, debugText,
        style=label.style_label_down,
        color=color.yellow,
        textcolor=color.black)

2. Table-Based Variable Monitor

// Real-time variable monitor table
var table debugTable = table.new(position.top_right, 2, 10,
    bgcolor=color.new(color.black, 80), border_width=1)

if barstate.islast
    table.cell(debugTable, 0, 0, "Variable",
        bgcolor=color.gray, text_color=color.white)
    table.cell(debugTable, 1, 0, "Value",
        bgcolor=color.gray, text_color=color.white)

    table.cell(debugTable, 0, 1, "Bar Index", text_color=color.white)
    table.cell(debugTable, 1, 1, str.tostring(bar_index), text_color=color.yellow)

    table.cell(debugTable, 0, 2, "Close", text_color=color.white)
    table.cell(debugTable, 1, 2, str.tostring(close, "#.####"), text_color=color.yellow)

    table.cell(debugTable, 0, 3, "Signal Active", text_color=color.white)
    sigColor = signalActive ? color.green : color.red
    table.cell(debugTable, 1, 3, signalActive ? "YES" : "NO", text_color=sigColor)

3. Loop Iteration Debugger

// Debug loop iteration (use for...in for safety)
var array<float> values = array.new<float>()
var int loopIterations = 0

loopIterations := 0

// ✅ PREFERRED: Use for...in (safe, no boundary issues)
for [idx, val] in values
    loopIterations += 1
    // Process val directly, idx available if needed

// Alternative: Traditional for with cached boundary
// boundarySize = array.size(values)
// for i = 0 to boundarySize - 1
//     loopIterations += 1

if barstate.islast
    label.new(bar_index, high,
        "Loop ran " + str.tostring(loopIterations) + " times\n" +
        "Array size: " + str.tostring(array.size(values)))

4. Repainting Detector

// Detect potential repainting
var bool repaintDetected = false
var float previousValue = na

if not barstate.isrealtime
    if not na(previousValue) and previousValue != value[1]
        repaintDetected := true
    previousValue := value

if barstate.islast and repaintDetected
    label.new(bar_index, high * 1.1, "⚠️ REPAINTING DETECTED",
        style=label.style_label_down,
        color=color.red,
        textcolor=color.white)

5. NA Value Tracker

// Debug na propagation
debugNa() =>
    result = "NA Debug:\n"
    result += "value1: " + (na(value1) ? "NA ❌" : "OK ✓") + "\n"
    result += "value2: " + (na(value2) ? "NA ❌" : "OK ✓") + "\n"
    result += "result: " + (na(result) ? "NA ❌" : "OK ✓")
    result

if barstate.islast
    label.new(bar_index, low, debugNa(),
        style=label.style_label_up,
        color=color.orange)

6. Security Function Debugger

// Debug request.security() calls
[htfClose, htfTime] = request.security(syminfo.tickerid, "D",
    [close, time],
    lookahead=barmerge.lookahead_off)

if barstate.islast
    secDebug = "HTF Debug:\n"
    secDebug += "Close: " + str.tostring(htfClose, "#.##") + "\n"
    secDebug += "Time:
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!

24212 skills3 agents1 MCP
Get the whole plugin

Stars on GitHub

Momentum

stars in total
242
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-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-optimizer

pine-optimizer

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

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…

ccxt9d45k
@ccxt@ccxtInstall Skill

Questions about pine-debugger.

Which coding agents can use pine-debugger?
pine-debugger 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.