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

请求编写Pinescript指标:价格穿越23000/22000时触发警报

Pine Script 指标实现:价格穿越特定价位触发警报

以下是满足需求的Pine Script代码,当价格向下跌破23000或向上突破22000时,会生成可视化信号并支持触发警报:

//@version=5
indicator("价位穿越警报", overlay=true)

// 定义关键价位
upper_level = 23000
lower_level = 22000

// 检测价格穿越条件
down_cross = ta.crossunder(close, upper_level)  // 收盘价向下穿越23000
up_cross = ta.crossover(close, lower_level)    // 收盘价向上穿越22000

// 绘制关键价位水平线,方便直观观察
plot(upper_level, color=color.red, title="23000 水平线", linewidth=2)
plot(lower_level, color=color.green, title="22000 水平线", linewidth=2)

// 生成信号标记,在K线附近显示提示
plotshape(down_cross, title="向下穿越23000", location=location.belowbar, color=color.red, style=shape.labelup, text="跌破23000", textcolor=color.white)
plotshape(up_cross, title="向上穿越22000", location=location.abovebar, color=color.green, style=shape.labeldown, text="突破22000", textcolor=color.white)

// 设置警报触发条件
alertcondition(down_cross, title="向下穿越23000警报", message="价格已向下穿越23000")
alertcondition(up_cross, title="向上穿越22000警报", message="价格已向上穿越22000")

使用说明:

  • 代码基于Pine Script v5编写,直接复制到TradingView的指标编辑器即可使用
  • 红色水平线对应23000价位,绿色水平线对应22000价位
  • 满足穿越条件时,K线下方会出现红色提示标签,上方会出现绿色提示标签
  • 配置警报:在TradingView的警报功能中,选择该指标,再对应勾选两个警报条件即可触发通知

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.08.22 07:54:18