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

问题描述

试图获得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]函数中使用了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