在pinescript中将系列整数转换为整数 [英] Converting series integer to integer in pinescript

查看:206
本文介绍了在pinescript中将系列整数转换为整数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用pinescript,并且我一直在尝试弄清以下代码为什么不起作用.控制台不断显示series [integer]无法输出整数.我知道系列与非系列值不兼容.如果是这样,是否有办法将series [integer]更改为整数?

I am using pinescript, and I have been trying to figure out why the following code does not work. The console keeps showing that series[integer] cannot output integer. I understand that series is not compatible with non-series values. If this is the case, is there a way to change series[integer] to 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)

以下代码有效:

z = highest(cci, 9) //assuming xy is 9
plot(z)

任何帮助将不胜感激.谢谢

Any help would be greatly appreciated. Thank you

托马斯

推荐答案

无法将pinescript中的系列整数转换为整数.因此,有必要寻找解决方法.您可以使用以下脚本.

Converting series integer to integer in pinescript to cannot be done. Therefore, it is necessary to look for workarounds. In your case, you can use the following script.

//@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中将系列整数转换为整数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆