【发布时间】:2020-10-02 21:05:20
【问题描述】:
我想为最近 5 根蜡烛内的价格范围的背景着色。 获取其中的最高价和最低价并为背景着色。 其他之前的蜡烛(蜡烛 6 和之前的蜡烛)我只想忽略。
我是新手,还在学习。
我尝试使用:
highest(5)
lowest(5)
和
highest(high, 5)
lowest(low, 5)
但这对我不起作用。
这是 Kodify web 的壁橱示例表单。但需要手动输入价格范围。
//@version=4
study(title="Colour background in price range", overlay=true)
// STEP 1:
// Configure price range with inputs
rangeUp = input(title="Price Range Upper Bound", type=input.float, defval=1, minval=0)
rangeDown = input(title="Price Range Lower Bound", type=input.float, defval=0.95, minval=0)
fullBarInRange = input(title="Full Bar In Range?", type=input.bool, defval=false)
// STEP 2:
// Check if bar falls in range, based on input
insideRange = if fullBarInRange
high < rangeUp and low > rangeDown
else
high > rangeDown and low < rangeUp
// STEP 3:
// Plot range's upper and lower bound
ubPlot = plot(series=insideRange ? rangeUp : na, style=plot.style_linebr, transp=100, title="Upper Bound")
lbPlot = plot(series=insideRange ? rangeDown : na, style=plot.style_linebr, transp=100, title="Lower Bound")
// STEP 4:
// Fill the background for bars inside the price range
fill(plot1=ubPlot, plot2=lbPlot, color=#FF8C00, transp=75)
【问题讨论】:
标签: plot pine-script highest