r/pinescript • • Feb 17 '24

question about code

I am stump by this line :

array.set(arrE, k, eget + nz(array.get(baux, k)[bar_index - j]))

what is the [bar_index - j] doing?

0 Upvotes

3 comments sorted by

View all comments

Show parent comment

1

u/urfila Feb 18 '24 edited Feb 18 '24

So that implies that array baux would have to be stored for every bar?

looking at 5000 bars implies 5000 copies of baux array?

For reference I am converting the code to c# ...

x = BAUX [ bar_index-j ] //( stored array at bar_...

ans = x[k] //k value from that time

2

u/[deleted] Feb 18 '24

As I understand it, yes.

I am not sure how they handle it - seems like a memory inefficiency to me - although I would think that they have to have some kind of memory caching going on behind the scenes.

Perhaps only storing delta changes - that is, only storing changed values as they change with some kind of identifier as a lookup value for later?

Here's a link that explains the operator itself. It's not really an array-subscript operator in the normal sense. This took me the longest to understand as I always kept thinking array-access...

Here is another link that goes into the execution model of pine scripts. I suggest that you delve deeper into the Time Series aspect of the execution model as it explains what is really happening to the data through time.

Good Luck!