如何获得pinescript中以前最高的值?

时间:2020-09-25 13:59:57

标签: plot user-defined-functions pine-script trading algorithmic-trading

试图获得pinescript中先前最高价的值,但是这段代码为我提供了当前最高最高价的前一柱。

myper=input(50, "LENGTH")
y1 = highest(high,myper)
yy = valuewhen(high>y1[1],high,0)
plot(yy[1], linewidth=2, color=#00FF00, title="alt")

任何人都可以帮忙吗?

1 个答案:

答案 0 :(得分:0)

那是因为您在[1]函数中使用了yy系列的前一个值(plot())。

//@version=4
study("My Script")
myper=input(50, "LENGTH")
y1 = highest(high,myper)
yy = valuewhen(high>y1[1],high,0)
plot(yy, linewidth=2, color=#00FF00, title="alt")

enter image description here