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

Pine Script如何在设置面板实现ORB高低线的上下点位偏移

ORB指标自定义偏移功能修改

修改逻辑:

  • 新增2个可在指标设置面板调整的参数,分别控制ORB高线上移、ORB低线下移的点位
  • 偏移量适配所有交易品种的最小报价单位,不需要手动换算价格偏移值
  • 完全保留原代码的ORB高低点统计、时段设置、时间周期过滤等原有逻辑

修改后完整代码:

//@version=4
study("ORB", overlay = true)

inputMax = input(5, title= "ORB总时长(分钟)")
sess = input("0915-0920", type=input.session, title="统计时段") 
// 新增自定义偏移参数
high_offset = input(0, title="ORB高线向上偏移点数", minval=0)
low_offset = input(0, title="ORB低线向下偏移点数", minval=0)

t = time(timeframe.period, sess + ":1234567")
hide = timeframe.isintraday and timeframe.multiplier <= inputMax

is_newbar(res) => change(time(res)) != 0
in_session = not na(t)
is_first = in_session and not in_session[1]

orb_high = float(na)
orb_low = float(na)

if is_first
    orb_high := high
    orb_low := low
else
    orb_high := orb_high[1]
    orb_low := orb_low[1]
if high > orb_high and in_session
    orb_high := high
if low < orb_low and in_session
    orb_low := low

// 计算偏移后用于绘图的高低线数值
plot_high = orb_high + high_offset * syminfo.mintick
plot_low = orb_low - low_offset * syminfo.mintick

plot(hide ? plot_high : na , style=plot.style_line, color=plot_high[1] != plot_high ? na : color.green, title="ORB高线", linewidth=2)
plot(hide ? plot_low : na , style=plot.style_line, color=plot_low[1] != plot_low ? na : color.red, title="ORB低线", linewidth=2)

使用说明:

  • 偏移参数默认值为0,此时显示效果和原指标完全一致
  • 参数输入数值为对应品种的最小变动点位数量,比如交易品种最小变动价位为0.01,输入10即对应价格偏移0.1
  • 所有原有参数的设置逻辑不变,可按需调整ORB统计时长、统计时段

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.08.26 13:36:17