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

TradingView警报中strategy.order.comment显示订单ID而非注释的问题

TradingView策略注释在警报中显示异常的排查方案
  • 注释字符串引号冲突:你的comment参数里嵌套了双引号,Pine Script解析时会出现语法错误,导致注释未被正确识别。需对内部双引号转义,或改用单引号包裹内部内容:

    // 转义双引号写法
    strategy.entry(id="Short", direction=strategy.short, stop=ShortEntry, comment="{\"alertId\": \"ea581e08-d600-4fd9-b6a6-9185cfd5f737\"}")
    
    // 单引号包裹内部内容写法
    strategy.entry(id="Short", direction=strategy.short, stop=ShortEntry, comment="{'alertId': 'ea581e08-d600-4fd9-b6a6-9185cfd5f737'}")
    
  • 验证警报变量正确性:确认警报消息中使用的是{{strategy.order.comment}},而非{{strategy.order.id}},避免因变量选错导致显示订单ID。

  • 检查策略内注释赋值逻辑:添加日志输出验证注释是否正确绑定到订单:

    if (strategy.position_size != strategy.position_size[1])
        label.new(bar_index, high, str.tostring(strategy.order.comment), color=color.red)
    

    触发订单时图表会显示注释内容,可直接确认是否是注释本身未被正确赋值。

  • 清除平台缓存:重新保存策略、刷新图表页面,或切换到Pine Script稳定版本,避免平台缓存导致参数不生效。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.08.03 00:25:20