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

如何在Pine Script中将填充区域向右偏移0.5单位?

Pine Script:将填充区域向右偏移0.5单位的解决方案

要让填充区域向右偏移0.5单位,只需给生成填充区域的两个plot对象添加offset参数即可,具体修改如下:

修改后的完整代码:

inFiveLH = ta.sma(low, 5) < ta.sma(close, 3) and ta.sma(close, 3) < ta.sma(high, 5) and ta.sma(low, 5) < ta.sma(close, 2) and ta.sma(close, 2) < ta.sma(high, 5) and ta.sma(low, 5) < ta.sma(close, 1) and ta.sma(close, 1) < ta.sma(high, 5)
plot(ta.sma(close,200), color = color.blue, linewidth= 3)
plot(ta.sma(high,5), color= inFiveLH?color.white: color.purple, linewidth = 1, style = plot.style_circles)
plot(ta.sma(low,5), color= inFiveLH?color.white: color.purple, linewidth = 1, style = plot.style_circles)
plot(ta.sma(close,50), color= color.blue, linewidth= 2)
plot(ta.sma(close,3), color=color.red, linewidth= 1)
plot(ta.sma(close,2), color= color.green, linewidth= 1)
plot(ta.sma(close,1), color= color.rgb(255, 247, 0), linewidth= 1)
plot(ta.vwap(close), color = color.white)
# 关键修改:添加offset=0.5参数
sma5H = plot(ta.sma(high,5), offset=0.5)
sma5L = plot(ta.sma(low,5), offset=0.5)
fill(sma5H,sma5L, color= inFiveLH?color.rgb(255, 255, 255, 79):color.rgb(0, 187, 212, 97) )

核心说明

offset参数用于控制plot在水平方向的偏移量,设置为0.5时,plot会向右移动半个K线单位,对应的填充区域也会同步偏移,正好匹配你需要的蜡烛实体左侧附近的位置。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.08.02 16:32:33