[英]Pine script series[string] to string conversion
I am trying to read symbols (strings) from an array, but array.get
returns a series[string] object, while security
only accepts simple strings.我正在尝试从数组中读取符号(字符串),但
array.get
返回一个 series[string] object,而security
只接受简单的字符串。 I tried casting to string, but it still gives a "series[string] argument is not accepted" error.我尝试转换为字符串,但它仍然给出“系列 [字符串] 参数不被接受”错误。 Is there a way to make this work?
有没有办法使这项工作?
//@version=4
study("etfa", shorttitle = 'etfa', max_bars_back=500, overlay = false)
length=input(40, title="length", type=input.integer)
sFunc(length) =>
kkl=stoch(close,high,low,length)
kkl
aaa=array.new_float(0,0)
aa=array.new_string(4, "text")
array.set(aa,0,"AAPL")
array.set(aa,1,"MSFT")
array.set(aa,2,"AMZN")
array.set(aa,3,"GOOGL")
for i = 0 to 3
k=array.get(aa,i)
r=string(k)
rr=security(r, timeframe.period,sFunc(length))
array.push(aaa,rr)
I'm afraid this is not possible in Pine for the moment.恐怕目前这在 Pine 中是不可能的。
The security
function needs a non-mutable string as the input for the ticker. security
function 需要一个不可变字符串作为股票代码的输入。
There's no way around that for the moment afaik.目前没有办法解决这个问题。
also tried this approach but this one also doesn't work也尝试过这种方法,但这也行不通
//@version=5
indicator('Test', overlay=true)
array_test = array.new_string(5, 'BTCUSDT')
array.set(array_test, 0, 'ETHUSDT')
array.set(array_test, 1, 'ADAUSDT')
array.set(array_test, 2, 'SOLUSDT')
array.set(array_test, 3, 'KARUSDT')
array.set(array_test, 4, 'ONEUSDT')
plot(request.security(str.tostring(array.get(array_test, math.round(math.random(0,4)))), 'D', close))
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.