Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Pine script series[string] to string conversion

Tags:

pine-script

I am trying to read symbols (strings) from an array, but array.get returns a series[string] object, while security only accepts simple strings. 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)
like image 561
Will Bir Avatar asked Feb 16 '26 15:02

Will Bir


1 Answers

I'm afraid this is not possible in Pine for the moment.
The security function needs a non-mutable string as the input for the ticker.
There's no way around that for the moment afaik.

like image 100
Bjorn Mistiaen Avatar answered Feb 19 '26 08:02

Bjorn Mistiaen



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!