首页 > 解决方案 > 摆动低点被打破后寻找最高开盘价

问题描述

上面的代码失败并显示错误消息。任何帮助都会有所帮助

//@version=4
study("count", overlay = true)
swh = pivothigh(high,2,1)
swl = pivotlow(low,2,1)
Bcount = barssince(swh)
// plot(Bcount)
highestOpen = valuewhen(crossunder(low,swl), highest(open,Bcount+1),0)
plot(highestOpen)

标签: pivotpine-script

解决方案


问题是最初的条形图Bcount = barssince(swh)是 0。

//@version=4
study("count", overlay = true, max_bars_back = 100)
swh = pivothigh(high,2,1)
swl = pivotlow(low,2,1)
Bcount = nz(barssince(swh))
// plot(Bcount)
highestOpen = valuewhen(crossunder(low,swl), highest(open,Bcount+1),0)
plot(highestOpen)

推荐阅读