我有一定的编码背景,通常我可以解决这个问题,但是我浏览了论坛和Google并没有找到解决方案。基本上,我要从highestbars()或lowestbars()输出,然后将其放在close []中。对此没有快速的解决方案,因为highestbars()/ lowestbars()输出数据类型Series [integer],而“ close”采用整数。
我已经尝试过使用for循环遍历相同数量的烛台并检查最高/最低价格,但这不起作用。我试图只输出最高和最低值,以将其与highest()和lower()进行比较,但它甚至还差得远。
由于我一直坚持下去,任何帮助将不胜感激。
//@version=4
study("Highest and Lowest Zones", overlay=true)
float high_close = close[12]
float last_close_high = high_close
int high_bar = highestbars(64)[12]
high1 = highest(64)[12]
low1 = lowest(64)[12]
for i = 0 to 64
closeHigh = (high[i+13] > high[i+12])
high_close := closeHigh ? close[i]: last_close_high
last_close_high := high_close
p1 = plot(high1, title="High", color=color.red)
p2 = plot(high_close, title="Low", color=color.red)
fill(p1, p2)
float low_close = close[12]
float last_close_low = low_close
for i = 0 to 64
closeLow = (low[i+13] > low[i+12])
low_close := closeLow ? close[i+13]: last_close_low
last_close_low := low_close
p3 = plot(low1, title="High", color=color.green)
p4 = plot(low_close, title="Low", color=color.green)
fill(p3, p4)
答案 0 :(得分:1)
这对我有用:
plot(close[0-highestbars(10)])