[英]Pincescript to get the average of high and low values
我从交易视图中获得了以下代码。 如何从标记中添加另一条高点和低点的平均线。
示例:以下代码将图表标记为 5 分钟时间范围内 30 分钟蜡烛的最高点和最低点。 所以,我想添加另一条高点和低点的平均线。
study(title="ORB-30Min", shorttitle="ORB30", overlay=true)
up30on = input(true, title="35 Minute Opening Range High")
down30on = input(true, title="35 Minute Opening Range Low")
is_newbar(res) => change(time(res)) != 0
adopt(r, s) => security(tickerid, r, s)
high_range = valuewhen(is_newbar('D'),high,0)
low_range = valuewhen(is_newbar('D'),low,0)
high_rangeL = valuewhen(is_newbar('D'),high,0)
low_rangeL = valuewhen(is_newbar('D'),low,0)
//averaged = (high_rangeL + low_rangeL)/2
up30 = plot(up30on ? adopt('30', high_rangeL): na, color = #333fff, style=line, linewidth=1)
down30 = plot(down30on ? adopt('30', low_rangeL): na, color = #333fff, style=line, linewidth=1)
//ave = plot(down30on ? adopt('30', low_rangeL): na, color = #e97d53, style=line, linewidth=1)
trans30 = up30on ? 97 : 100
fill(up30, down30, color = white, transp=trans30)
//@version=4
study(title="ORB-30Min", shorttitle="ORB30", overlay=true)
up30on = input(true, title="35 Minute Opening Range High")
down30on = input(true, title="35 Minute Opening Range Low")
avg30on = input(true, title="35 Minute Opening Range Average")
is_newbar(res) => change(time(res)) != 0
adopt(r, s) => security(syminfo.tickerid, r, s)
high_range = valuewhen(is_newbar('D'),high,0)
low_range = valuewhen(is_newbar('D'),low,0)
high_rangeL = valuewhen(is_newbar('D'),high,0)
low_rangeL = valuewhen(is_newbar('D'),low,0)
up30 = plot(up30on ? adopt('30', high_rangeL): na, color = #333fff, style=plot.style_stepline, linewidth=1)
down30 = plot(down30on ? adopt('30', low_rangeL): na, color = #333fff, style=plot.style_stepline, linewidth=1)
avg30 = plot(avg30on ? adopt('30', avg(high_rangeL,low_rangeL)): na, color = #e97d53, style=plot.style_stepline, linewidth=1)
color30 = up30on ? color.new(color.white,97) : color.new(color.white,100)
fill(up30, down30, color = color30)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.