抱歉,我的编码太生疏了,我正在尝试找出 pinescript。
我试图添加时间变量的简单脚本。 目标是仅在 RTH(纽约交易时间)内显示情节。
我已经了解到“IF 语句必须位于绘图命令内,而不是相反”,但我似乎无法再进一步了。 请帮忙。
study("Pivot High Low Points", overlay =true)
t = time(timeframe.period, "0930-1600")
time_cond = not na(t)
lb = input(defval = 5, title="Left Bars")
rb = input(defval = 5, title="Right Bars")
mb = lb + rb + 1
plotshape(iff(not na(high[mb]), iff(highestbars(mb) == -lb, high[lb], na), na), style = shape.triangledown, location = location.abovebar, color = color.red, size = size.tiny, offset = -lb)
plotshape(iff(not na(low[mb]), iff(lowestbars(mb) == -lb, low[lb], na), na), style = shape.triangleup, location = location.belowbar, color = color.lime, size = size.tiny, offset = -lb)
问题是,如何将“if and time_cond”插入到plotshape命令中? 谢谢!
想不通。 不会编译
将 if 条件分配给变量,然后使用
and
time_cond
。
high_cond = iff(not na(high[mb]), iff(highestbars(mb) == -lb, high[lb], na), na)
low_cond = iff(not na(low[mb]), iff(lowestbars(mb) == -lb, low[lb], na), na)
high_plot = high_cond and time_cond
low_plot = low_cond and time_cond
plotshape(high_plot, style = shape.triangledown, location = location.abovebar, color = color.red, size = size.tiny, offset = -lb)
plotshape(low_plot, style = shape.triangleup, location = location.belowbar, color = color.lime, size = size.tiny, offset = -lb)
注意: 由于您在
offset
中使用了 plotshape()
,因此您可能需要根据需要调整时间条件。