在pinescript中将系列整数转换为整数
Converting series integer to integer in pinescript
我使用的是pinescript,我一直在想为什么下面的代码不起作用。控制台一直显示 series[integer] 无法输出整数。我知道该系列与非系列值不兼容。如果是这种情况,有没有办法将系列[整数]更改为整数?
The following code does not work:
x = barssince(crossover(cci,100))
y = barssince(crossover(100,cci))
xy = x-y //in this case the xy value is 9
z = highest(cci, abs(xy))
plot(z)
The following code works:
z = highest(cci, 9) //assuming xy is 9
plot(z)
如有任何帮助,我们将不胜感激。谢谢
托马斯
无法在 pinescript 中将系列整数转换为整数。
因此,有必要寻找解决方法。对于您的情况,您可以使用以下脚本。
//@version=4
study("Help (hi/lo between conditions)")
cci = cci(close, 14)
plot(cci, title="cci")
hline(100)
hline(-100)
up_top_boder = crossover(cci,100)
dn_top_boder = crossunder(cci,100)
up_bottom_boder = crossover(cci,-100)
dn_bottom_boder = crossunder(cci,-100)
hi = float(na)
lo = float(na)
var look_hi = false
var look_lo = false
if up_top_boder or look_hi
if dn_top_boder
look_hi := false
else
look_hi := true
hi := max(cci, nz(hi[1]))
if dn_bottom_boder or look_lo
if up_bottom_boder
look_lo := false
else
look_lo := true
lo := min(cci, nz(lo[1]))
plot(hi, title="hi", style=plot.style_circles, linewidth=2, color=color.green)
plot(lo, title="lo", style=plot.style_circles, linewidth=2, color=color.red)
我使用的是pinescript,我一直在想为什么下面的代码不起作用。控制台一直显示 series[integer] 无法输出整数。我知道该系列与非系列值不兼容。如果是这种情况,有没有办法将系列[整数]更改为整数?
The following code does not work:
x = barssince(crossover(cci,100))
y = barssince(crossover(100,cci))
xy = x-y //in this case the xy value is 9
z = highest(cci, abs(xy))
plot(z)
The following code works:
z = highest(cci, 9) //assuming xy is 9
plot(z)
如有任何帮助,我们将不胜感激。谢谢
托马斯
无法在 pinescript 中将系列整数转换为整数。 因此,有必要寻找解决方法。对于您的情况,您可以使用以下脚本。
//@version=4
study("Help (hi/lo between conditions)")
cci = cci(close, 14)
plot(cci, title="cci")
hline(100)
hline(-100)
up_top_boder = crossover(cci,100)
dn_top_boder = crossunder(cci,100)
up_bottom_boder = crossover(cci,-100)
dn_bottom_boder = crossunder(cci,-100)
hi = float(na)
lo = float(na)
var look_hi = false
var look_lo = false
if up_top_boder or look_hi
if dn_top_boder
look_hi := false
else
look_hi := true
hi := max(cci, nz(hi[1]))
if dn_bottom_boder or look_lo
if up_bottom_boder
look_lo := false
else
look_lo := true
lo := min(cci, nz(lo[1]))
plot(hi, title="hi", style=plot.style_circles, linewidth=2, color=color.green)
plot(lo, title="lo", style=plot.style_circles, linewidth=2, color=color.red)