You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何通过Pine Script隐藏信号标签?保留交易列表调试信息

用Pine Script隐藏图表信号标签但保留交易列表记录

针对策略内置的订单标签

直接在strategy()函数中添加plot_order_label=false参数,即可隐藏图表上的买卖订单标签,同时交易面板里的订单记录会完整保留,不影响调试:

//@version=5
strategy("My Strategy", overlay=true, plot_order_label=false)
// 策略逻辑示例
longCondition = ta.crossover(ta.sma(close, 5), ta.sma(close, 20))
if (longCondition)
    strategy.entry("Long", strategy.long)

shortCondition = ta.crossunder(ta.sma(close, 5), ta.sma(close, 20))
if (shortCondition)
    strategy.entry("Short", strategy.short)

针对自定义的信号标签

如果是通过label.new()手动创建的信号标记,可以用布尔变量控制显示状态,将开关设为false就能隐藏图表标签,同时不影响交易相关的记录逻辑:

//@version=5
strategy("Custom Signal Strategy", overlay=true)

// 控制图表标签显示的开关,设为false即可隐藏
var bool showChartLabels = false

longSignal = ta.crossover(ta.sma(close, 5), ta.sma(close, 20))
if (longSignal)
    // 仅当开关为true时才生成图表标签
    if showChartLabels
        label.new(bar_index, low, "L", color=color.green, textcolor=color.white)
    // 交易记录逻辑不受影响
    strategy.entry("Long", strategy.long)

shortSignal = ta.crossunder(ta.sma(close, 5), ta.sma(close, 20))
if (shortSignal)
    if showChartLabels
        label.new(bar_index, high, "S", color=color.red, textcolor=color.white)
    strategy.entry("Short", strategy.short)

以上设置后,无论脚本如何刷新,图表上都不会显示信号标签,交易列表的记录依然完整,完全满足调试需求。

内容的提问来源于stack exchange,提问作者dorien

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.25 04:02:02