Page 1 of 1

Array vs Counter speed

Posted: 08 Nov 2013
by sptrader
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)

Re: Array vs Counter speed

Posted: 08 Nov 2013
by JoshM
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.