pine-debugger by traderspost/pinescript-agents
npx skills add https://github.com/traderspost/pinescript-agents --skill pine-debugger专精于在 TradingView 通常不透明的环境中添加调试工具和排查 Pine Script 代码问题。
label.new() 以检查数值bar_index 追踪na 值传播Pine Script 不支持在没有正确语法的情况下跨多行分割表达式。这是常见的错误来源。
错误 - 将导致 "end of line without line continuation" 错误:
// 不要这样做 - 三元运算符跨行分割
dollarsText = priceDiff >= 0 ?
str.format("+${0}", priceDiff) :
str.format("-${0}", math.abs(priceDiff))
广告位招租
在这里展示您的产品或服务
触达数万 AI 开发者,精准高效
正确 - 将三元运算符保持在一行:
// 这样做 - 整个三元运算符在一行
dollarsText = priceDiff >= 0 ? str.format("+${0}", priceDiff) : str.format("-${0}", math.abs(priceDiff))
// 显示多个数值的调试标签
if barstate.islast
debugText = "RSI: " + str.tostring(rsiValue, "#.##") + "\n" + "MA: " + str.tostring(maValue, "#.##") + "\n" + "Signal: " + (buySignal ? "BUY" : "NEUTRAL")
label.new(bar_index, high * 1.05, debugText, style=label.style_label_down, color=color.yellow, textcolor=color.black)
// 实时变量监视表格
var table debugTable = table.new(position.top_right, 2, 10, bgcolor=color.black, 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 Price", 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)
table.cell(debugTable, 1, 3, signalActive ? "YES" : "NO", text_color=signalActive ? color.green : color.red)
// 追踪历史数值用于调试
var array<float> histValues = array.new<float>()
var array<int> histBarIndex = array.new<int>()
if condition
array.push(histValues, valueToTrack)
array.push(histBarIndex, bar_index)
if array.size(histValues) > 50 // 保留最后 50 个值
array.shift(histValues)
array.shift(histBarIndex)
// 显示历史数值
if barstate.islast and array.size(histValues) > 0
for i = 0 to math.min(array.size(histValues) - 1, 10)
label.new(array.get(histBarIndex, i), array.get(histValues, i), str.tostring(array.get(histValues, i)), style=label.style_circle, size=size.tiny)
// 检测潜在的重绘
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)
// 追踪计算流程
var string calcFlow = ""
calcFlow := "Step 1: Input = " + str.tostring(input) + "\n"
intermediate1 = input * 2
calcFlow := calcFlow + "Step 2: x2 = " + str.tostring(intermediate1) + "\n"
intermediate2 = intermediate1 + 10
calcFlow := calcFlow + "Step 3: +10 = " + str.tostring(intermediate2) + "\n"
result = intermediate2 / 3
calcFlow := calcFlow + "Step 4: /3 = " + str.tostring(result)
if barstate.islast
label.new(bar_index - 10, high, calcFlow, style=label.style_label_left, size=size.small)
// 调试 na 值传播
debugNa = "NA Debug:\n"
debugNa := debugNa + "Value1 is " + (na(value1) ? "NA" : "OK") + "\n"
debugNa := debugNa + "Value2 is " + (na(value2) ? "NA" : "OK") + "\n"
debugNa := debugNa + "Result is " + (na(result) ? "NA" : "OK")
// 调试序列/简单类型问题
// 如果类型混合不正确,将显示编译错误
debugSeriesType = ta.sma(close, 10) // series float
debugSimpleType = 10 // simple int
// debugWrong = debugSimpleType[1] // 错误:Cannot use [] on simple
// 调试 security() 调用
[htfValue, htfTime] = request.security(syminfo.tickerid, "D", [close, time])
if barstate.islast
label.new(bar_index, high, "HTF Close: " + str.tostring(htfValue) + "\n" + "HTF Time: " + str.format_time(htfTime, "yyyy-MM-dd HH:mm"))
添加初始调试点
追踪执行
识别问题
na 值测试边界情况
清理
debugMode = input.bool(false, "Debug Mode", group="Debug")
// 条件调试
if debugMode
// 所有调试代码放在这里
label.new(...)
table.cell(...)
TradingView 的环境是不透明的且经常变化。请务必彻底测试并提供多种调试方法。
每周安装数
106
代码仓库
GitHub 星标数
68
首次出现
Jan 23, 2026
安全审计
安装于
gemini-cli89
opencode88
codex84
github-copilot83
kimi-cli74
amp74
Specialized in adding debugging tools and troubleshooting Pine Script code in TradingView's often opaque environment.
Pine Script does NOT support splitting expressions across multiple lines without proper syntax. This is a frequent source of errors.
WRONG - Will cause "end of line without line continuation" error:
// DON'T DO THIS - Ternary split across lines
dollarsText = priceDiff >= 0 ?
str.format("+${0}", priceDiff) :
str.format("-${0}", math.abs(priceDiff))
CORRECT - Keep ternary on one line:
// DO THIS - Entire ternary on one line
dollarsText = priceDiff >= 0 ? str.format("+${0}", priceDiff) : str.format("-${0}", math.abs(priceDiff))
// Debug label showing multiple values
if barstate.islast
debugText = "RSI: " + str.tostring(rsiValue, "#.##") + "\n" + "MA: " + str.tostring(maValue, "#.##") + "\n" + "Signal: " + (buySignal ? "BUY" : "NEUTRAL")
label.new(bar_index, high * 1.05, debugText, style=label.style_label_down, color=color.yellow, textcolor=color.black)
// Real-time variable monitor table
var table debugTable = table.new(position.top_right, 2, 10, bgcolor=color.black, 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 Price", 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)
table.cell(debugTable, 1, 3, signalActive ? "YES" : "NO", text_color=signalActive ? color.green : color.red)
// Track historical values for debugging
var array<float> histValues = array.new<float>()
var array<int> histBarIndex = array.new<int>()
if condition
array.push(histValues, valueToTrack)
array.push(histBarIndex, bar_index)
if array.size(histValues) > 50 // Keep last 50 values
array.shift(histValues)
array.shift(histBarIndex)
// Display historical values
if barstate.islast and array.size(histValues) > 0
for i = 0 to math.min(array.size(histValues) - 1, 10)
label.new(array.get(histBarIndex, i), array.get(histValues, i), str.tostring(array.get(histValues, i)), style=label.style_circle, size=size.tiny)
// 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)
// Trace calculation flow
var string calcFlow = ""
calcFlow := "Step 1: Input = " + str.tostring(input) + "\n"
intermediate1 = input * 2
calcFlow := calcFlow + "Step 2: x2 = " + str.tostring(intermediate1) + "\n"
intermediate2 = intermediate1 + 10
calcFlow := calcFlow + "Step 3: +10 = " + str.tostring(intermediate2) + "\n"
result = intermediate2 / 3
calcFlow := calcFlow + "Step 4: /3 = " + str.tostring(result)
if barstate.islast
label.new(bar_index - 10, high, calcFlow, style=label.style_label_left, size=size.small)
// Debug na propagation
debugNa = "NA Debug:\n"
debugNa := debugNa + "Value1 is " + (na(value1) ? "NA" : "OK") + "\n"
debugNa := debugNa + "Value2 is " + (na(value2) ? "NA" : "OK") + "\n"
debugNa := debugNa + "Result is " + (na(result) ? "NA" : "OK")
// Debug series/simple type issues
// Will show compilation error if mixing types incorrectly
debugSeriesType = ta.sma(close, 10) // series float
debugSimpleType = 10 // simple int
// debugWrong = debugSimpleType[1] // Error: Cannot use [] on simple
// Debug security() calls
[htfValue, htfTime] = request.security(syminfo.tickerid, "D", [close, time])
if barstate.islast
label.new(bar_index, high, "HTF Close: " + str.tostring(htfValue) + "\n" + "HTF Time: " + str.format_time(htfTime, "yyyy-MM-dd HH:mm"))
Add Initial Debug Points
Trace Execution
Identify Issues
Test Edge Cases
Clean Up
debugMode = input.bool(false, "Debug Mode", group="Debug")
// Conditional debugging
if debugMode
// All debug code here
label.new(...)
table.cell(...)
TradingView's environment is opaque and changes frequently. Always test thoroughly and provide multiple debugging approaches.
Weekly Installs
106
Repository
GitHub Stars
68
First Seen
Jan 23, 2026
Security Audits
Gen Agent Trust HubPassSocketPassSnykPass
Installed on
gemini-cli89
opencode88
codex84
github-copilot83
kimi-cli74
amp74
Stripe API升级指南:版本控制、SDK更新与破坏性变更处理
3,600 周安装
Tavily AI 网站爬取工具 - 智能提取文档、知识库和全站内容
3,500 周安装
Vue.js测试最佳实践:Vue 3组件、组合式函数、Pinia与异步测试完整指南
4,000 周安装
Google Workspace CLI 教程:使用 gws 命令创建反馈表单并邮件分享
7,200 周安装
Google Workspace 事件订阅命令 gws-events-subscribe:实时流式监控与自动化处理
7,500 周安装
Google Calendar 会议重新安排技能 - 自动更新会议时间并通知参与者
7,500 周安装
Google Workspace CLI 团队负责人技能:自动化站会、任务协调与团队沟通工具
7,500 周安装