我正在尝试用松木编写一个脚本,当价格突破前15分钟蜡烛的高/低价格时,该脚本将触发一系列操作。我该怎么办?
我在线遇到了以下代码:
study(title="OR", shorttitle="OpeningRange", overlay=true)
up15on = input(true, title="15 Minute Opening Range High")
down15on = input(true, title="15 Minute Opening Range Low")
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)
up15 = plot(up15on ? adopt('15', high_rangeL): na, color = #53cbe9, style=plot.style_line, linewidth=1)
down15 = plot(down15on ? adopt('15', low_rangeL): na, color = #e97d53, style=plot.style_line, linewidth=1)
trans15 = up15on ? 97 : 100
fill(up15, down15, color = color.white, transp=trans15)
上面的代码在图表上将高/低绘制为一条线,但是我不希望在图表上绘制这些值。我希望这些值作为变量。我试图弄清楚这部分的作用:up15on ? adopt('15', high_rangeL): na, color = #53cbe9, style=plot.style_line, linewidth=1
我不明白为什么有条件要用accept('15',high_rangeL)检查up15on。如果有人可以解释我将不胜感激。
修改后的代码:
study(title="OR", shorttitle="OpeningRange", overlay=true)
up15on = input(true, title="15 Minute Opening Range High")
down15on = input(true, title="15 Minute Opening Range Low")
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)
candle_color = close>adopt('15', high_range) ? color.purple :
close<adopt('15', low_range) ? color.yellow :
na
barcolor( candle_color )