[英]pivothigh/pivotlow not working as expected
为什么这段代码向我显示错误的数据透视高点? 它正在计算左侧和右侧的每一秒栏,而不仅仅是一个...如果我更改为:
bar_index % 1 == 0
,它工作正常。
这是我的代码:
//@version=4
study("fckn test", overlay=true)
if bar_index % 2 == 0
ph = pivothigh(1,1)
label.new(bar_index-1, low, tostring(ph))
不太确定您要做什么。 也许这个?
//@version=4
study("fckn test", overlay=true)
pivotLegs = 1
// Find pivot outside `if` block because needs to run on every bar.
ph = pivothigh(pivotLegs, pivotLegs)
// Detect a new pivot.
newPh = not na(ph)
// If a new pivot is found, save the bar index where it was found.
bh = newPh ? bar_index - pivotLegs : na
if bar_index % 2 == 0 and not na(ph)
label.new(bh, high[pivotLegs], tostring(ph))
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.