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

Pine Script如何创建单个告警实现带标的信息的买卖信号通知

单告警双向信号通知实现方案

你可以通过Pine Script内置的syminfo.ticker变量获取当前标的代码,将其与买卖信号文本拼接后统一触发告警,仅需创建1个告警即可实现双向通知。

完整示例代码

//@version=5
indicator("双向买卖信号单告警", overlay=true)

// 替换为你自己的买卖信号判断逻辑即可
buy = ta.crossover(close, ta.sma(close, 20))
sell = ta.crossunder(close, ta.sma(close, 20))

if buy or sell
    // 拼接信号标识+标的代码
    alert_content = buy ? "BUY " + syminfo.ticker : "SELL " + syminfo.ticker
    // 触发告警,触发频率可根据需求调整
    alert(alert_content, alert.freq_once_per_bar_close)

配置说明

  • 创建告警时,告警消息来源选择「指标的告警消息」,不需要额外自定义消息模板
  • 告警触发频率可选:alert.freq_once_per_bar(每根K线触发1次)、alert.freq_once_per_bar_close(K线收盘后触发1次)、alert.freq_all(每次价格变动满足条件都触发)
  • 如需补充标的全称,可以拼接syminfo.description变量,例如"BUY " + syminfo.ticker + " " + syminfo.description

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.10.03 16:45:04