Put indicator values into an array

 

Is it possible to take the values of an indicator and put them into an array so that the values of the indicator can be looped through. I have tried for a while to find a way to do this but can't work it out.


Below iis the core of the code for an indicator to mark spike highs (it allows for bars with equal tops within the spike pattern)

Can I put the values of SpikeHi[] for the most recent 20 or so bars into an array so that I can loop through them to look for particular patterns of highs (e.g. look for higher spike highs or lower spike highs etc.)

//SPIKE HIGHS
// if there is a lower high then look for a spike high


//A. loop back to find first bar of pattern
   if(High[i+1] < High[i+2])
   {
      int ShiftOfFirstBarOfSH = 3; // i.e. the bar furthest from the right edge of the chart
      while
      (   
         i+ShiftOfFirstBarOfSH < Bars // check for running out of bars
         && High[i+ShiftOfFirstBarOfSH] >= High[i+(ShiftOfFirstBarOfSH-1)]
      )
         {
              ShiftOfFirstBarOfSH++;
         }
   }

// B. loop forward to find 2nd last bar of pattern - which is bar marked by indicator   
   if(High[i+1] < High[i+2])
   {
      int ShiftOfSHmarker = ShiftOfFirstBarOfSH-1;
      while
      (
         i+ShiftOfSHmarker > Bars
         && High[i+ShiftOfSHmarker] == High[i+(ShiftOfSHmarker-1)]
      )
         {
            ShiftOfSHmarker++;
         }
   }
   
   if(High[i+1] < High[i+2] && High[i+ShiftOfFirstBarOfSH] < High[i+(ShiftOfFirstBarOfSH-1)])
   {
      SpikeHi[i+ShiftOfSHmarker] = High[i+ShiftOfSHmarker];
   }
   else SpikeHi[i+ShiftOfSHmarker] = 0;
 

i realy dont understand

each indicator is already stored into an array, why store it into another one

iCustom

Reason: