Page 1 of 1

Array of stings (ticker codes) - converting "string series" to "simple string"

Posted: Sun Jan 16, 2022 5:56 pm
by DrBuffet
Hi - I have a challenge I hope one of you can help me with ... :zen:

in an indicator script, I would like to build a (predefined) list of ticker-symbols/strings (eg "NASDAQ:AAPL" as part of a NASDAQ ticket list) and use these in the script values as inputs to the request.security() function - eg ala

var symbol_array = array.new_string(25, "" )

if barstate.isfirst
<indent> array.set(symbol_array, 0, "NASDAQ:AAPL")

float symbol_close = request.security(array.get(symbol_array, 0), timeframe='D', expression=close)"
// to be equivalent to "request.security("NASDAQ:AAPL", timeframe='D', expression=close)"

the problem is that array.get() returns a "string series" and the request.security() expects a "simple string" as parameter

so how do I "convert" the "string series value" to a "simple string" ??

or is there another way to define such a list of symbols not using arrays?

or??

Thanks in advance
Claus from Denmark

Re: Array of stings (ticker codes) - converting "string series" to "simple string"

Posted: Sun Jan 23, 2022 10:49 pm
by Deep-Wave
Hi Claus,
if there isn't a specific reason for using arrays, you could simply define the list as "var string" variables and use these as the inputs to your request security function.
It might be easier.
https://www.tradingview.com/pine-script ... ht=var#var
Good luck with your coding and best regards, :cool:

Mark