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

# Proper arrays in Pine in the future?? Edit Subject

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 ?

big thanks!
Eugene
13 people like
this idea
• Yes, regular usual arrays are absolutely necessary for complex calculations.
How does this make you feel?
I'm
• Or if we had lists, vectors, dictionaries, and classes that would be nice too!
How does this make you feel?
I'm
• 1
Please make some kind of simple heap at least.
How does this make you feel?
I'm
How does this make you feel?
I'm
• It would be super cool if trading view answered this topic. Without the ability to arrays or assign values to another value in a series other than the current it really impedes the ability to make any innovative indicators.
How does this make you feel?
I'm
• Amen to that!!! The only way to do it is if you build out all your indicators on your own website with your own build of the tradingview. Which also requires you to get a data provider and etc. So I would love for them to make it available on tradingview.com. The problem I think why it hasn't is that it's a memory thing. If your indicator builds an array,vector, etc. It could be a huge file, which takes up resources, and huge server cycles , Plus, if you don't code it just right you could do and infinite loop which would also be really bad for the server. So I think that is why things in this arena aren't happening. I have my doubts that they will. Again, your best bet is Javascript on your own server.
How does this make you feel?
I'm
• Yeah I'm thinking that may be the best option. It seems automated trading isn't really on their roadmap either so I might as well just build my own system from the ground up.

Your saying though I could TV charts and add custom indicators to the chart via javascript? If I host the chart and setup my own data streams?
How does this make you feel?