Array vs Counter speed

Studies that have been contributed to the community by other users. If you’ve got something useful to share, that’s great!
sptrader
Posts: 742
Joined: 09 Apr 2010
Location: Texas
Has thanked: 483 times
Been thanked: 274 times
Contact:

Array vs Counter speed

Postby sptrader » 08 Nov 2013

It probably doesn't matter much due to the small size but I was wondering if there is a resource and speed preference, between a counter and an array that both store and sum intra-day data over a 20 day period ? (for calculating ADR etc)

User avatar
JoshM
Posts: 2195
Joined: 20 May 2011
Location: The Netherlands
Has thanked: 1544 times
Been thanked: 1565 times
Contact:

Re: Array vs Counter speed

Postby JoshM » 08 Nov 2013

It probably doesn't matter much due to the small size but I was wondering if there is a resource and speed preference, between a counter and an array that both store and sum intra-day data over a 20 day period ? (for calculating ADR etc)
If I understand you correctly, a counter will be quicker. With an array, you either have to (a) loop through the array to determine the sum or (b) loop through the last bars to fill the array and then loop through the array to calculate the sum.

If situation (b), a simple variable will be quicker since that saves the time to loop through the array.


Return to “User Contributed Studies and Indicator Library”