Help get this topic noticed by sharing it on Twitter, Facebook, or email.
I’m thankful

Proper arrays in Pine in the future??

Hello
i wonder if proper arrays are on the list for Pine script development?
I am well familiar with the series and [] as historical reference - very nice concept.

But supposed I want to calculate a super clever moving average (actual i don't but i have a diff purpose). And it's equation is as follows :

X = sum ( C{n} x Price[n])

where Price[n] are indeed past bars as usual, but the C{n} - I am deliberately using {} here - are coefficient which are all calculated for every current bar and used at once. They have no historical reference to the bars before and are recalculated anew for every bar.

If I had proper arrays where I can store all of the coefs at once in an array, I could calculate X in a loop. But I cannot figure out how to do it with the series, as I cannot assign past values to the series at the current bar. So cannot do this (or can I?)
//at current bar
C[5] = 5
C[4] = 4 etc
then calculate X in a loop.

Right now I am having to use variables for each coef, thus I cannot do loop summations, and I have 50 coeffs...it's terrrible...it just becomes unmanageable.

Having these arrays would enable plotting all sorts of two-dimensional statistics as heat-maps - for example etc.
So I wonder:
1. are the arrays on the list for future feature ?
2. can what I described be done with the series ?

Overall, love TradingView, love Pine!
big thanks!
Eugene
13 people like
this idea
+1
Reply