1

I'm trying to make some sort of correlation by power study. The plan is to draw all elements of an industry, average and SPX. The industry is chosen depending on which ticker you are looking at.

I run into the problem that I can't use members of an array to call security(). I'm looking for any workaround or solution:

banks = array.new_string(0)
array.push(banks, "BAC")
array.push(banks, "JPM")
array.push(banks, "C")
array.push(banks, "WFC")

rocPeriod = input(30, minval = 1)
perc_change = roc(close, rocPeriod)

for i = 0 to array.size(result)
    var sec = security(array.get(result, i), res, perc_change)

This code doesn't work because security() expects string, but arrays get() return series[string] by some reason.

Any ideas?

Thanks

Ambrase
  • 57
  • 1
  • 10
  • 1
    Recently discussed https://stackoverflow.com/questions/65629613/extracting-string-value-from-a-string-array-in-pine – AnyDozer Jan 17 '21 at 13:04
  • The workaround could be to use multiple plots like here: https://stackoverflow.com/questions/61579897/plotting-within-a-loop-cannot-use-plot-in-local-scope-tradingview-pine-scri – Ambrase Jan 17 '21 at 13:40
  • running into the same problem. would like to assign various tickers to an array, ans simply look through them, retrieve their timeseries and blend together. seems very basic problem...but so difficult in pinescript. is there a solution 4 years later to this? – mike01010 Dec 05 '21 at 18:32
  • I need this also... – Joseph Astrahan Apr 29 '23 at 02:06

0 Answers0