Announcement

Collapse
No announcement yet.

Which is faster?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Which is faster?

    Is there any time benefit to using an array to store high and low info as opposed to just reading the high and low info using high(-n) and low(-n) every time a new bar is detected?

    Let's say you need the high and low info for 50 bars on a 1 minute chart. Would it be faster to get the high and low info for each of the 50 bars in a for loop every time a new bar is detected, or load an array with 50 bars of high and low info just once and then rotate the info in the array, dropping off the oldest bar info and adding just the new bar high and low to the other end of the array?

    Dale

  • #2
    Dale,

    I would say that putting them in arrays takes more overhead. You can put it in an array many ways, with two below
    PHP Code:
    var nArray  getValueAbsolute"High"0, -25 );//one step
                   
                              
    or

    for (
    i=0;i<25;i++){nArray[i]= high(-i);}//iterative loop 
    The first method I believe takes less overhead, the second takes more. In both cases, the difference in execution time is inconsequential compared to the inclusion of one debugPrintln step or use of drawing tools. I like to use arrays to pass data to functions which contain Technical analysis tools. I can send price data, or I can send the outputs from technical indicators which I've saved in arrays to the same functions. aka indicator of an indicator...

    Comment

    Working...
    X