Pine script 无法调用';安全';与';符号'=系列[字符串]。参数的类型应为:string;

Pine script 无法调用';安全';与';符号'=系列[字符串]。参数的类型应为:string;,pine-script,trading,secure-trading,Pine Script,Trading,Secure Trading,我如何解决这个问题 如果我删除了安全功能,我会得到一个新的错误安全表达式中的可变变量。 安全功能是为了摆脱它。但现在我又犯了新的错误 错误: 第31行:无法使用'symbol'=series[string]调用'security'。 参数的类型应为:string 第33行:未声明的标识符“bs” 第34行:未声明的标识符“crs” //@version=4 study("CRS 3", shorttitle="CRS 3") a = syminfo.t

我如何解决这个问题

如果我删除了安全功能,我会得到一个新的错误安全表达式中的可变变量。 安全功能是为了摆脱它。但现在我又犯了新的错误

错误: 第31行:无法使用'symbol'=series[string]调用'security'。 参数的类型应为:string 第33行:未声明的标识符“bs” 第34行:未声明的标识符“crs”

//@version=4
study("CRS 3", shorttitle="CRS 3") 

a = syminfo.tickerid

input1 = input("DJI", type=input.symbol)
input2 = input("NIFTY1!", type=input.symbol)




//var string  b = na

//if  a == "NIFTY1!"
//    b := input1
//else
//    b := input2


cal_b() =>
    var string  b = na
    if  a == "NIFTY1!"
        b := input1
    else
        b := input2
    return = b



as = security(a, timeframe.period, close)                  //LINE 31
bs = security(cal_b(), timeframe.period, close)            

crs = as/bs                                                //LINE 33 
plot(crs, linewidth=1, color=color.black, title="CRS", display=display.all, transp=0) //LINE 34 


不能使用
符号
参数的可变变量调用
security()

它必须是一个固定值,在脚本执行期间不会更改

类似这样的方法会奏效:

//@version=4
study("CRS 3", shorttitle="CRS 3") 

input1 = input("DJI", type=input.symbol)
input2 = input("NIFTY1!", type=input.symbol)

var float bs = na

a = syminfo.ticker

as = security(a, timeframe.period, close)

bs1 = security(input1, timeframe.period, close)
bs2 = security(input2, timeframe.period, close)

if  a == "NIFTY1!"
    bs := bs1
else
    bs := bs2

crs = as/bs
plot(crs, linewidth=1, color=color.black, title="CRS", display=display.all)

如果不是,条件;当a==“NIFTY1!”时,在第一个条件下不工作。这是被绕过的。这是因为
syminfo.tickerid
还包括交换名称:
NSE:NIFTY1。如果您使用的
syminfo.ticker
将有没有交易所名称的股票代码名称:
NIFTY1。我已经编辑了我的答案,并将
a=syminfo.tickerid
更改为
a=syminfo.ticker
。那会有用的。非常感谢你的真诚努力。我诚挚的感谢和衷心的感谢。似乎有一个新的问题,它将无法与以前的功能。似乎“a”也必须用于If-then条件。如果a=nifty,则a=syminfo.tickerid,否则a=syminfo.ticker。你能帮我做最后一次代码吗?再一次,请接受我最深切的感谢。我已经提出了if then条件并解决了这个问题。谢谢你,比约恩·米斯丁