Find maximum range (iHigh-iLow) in last X bars

 

Hi all,


I try write function in my EA which find maximum range (in points) for last (for example) 5 bars. But my code always return NULL.

What I can:

Get High and Low values for current bar (and bar[1],bar[2],bar[3],...), calculate range and convert to points.

Create array of (last 5) ranges and find maximum value (probably ArrayMaximum).


My code:

int check(){

   for(int i = 0; i <= 5; i++) { 

      double iHigh[i] = iHigh("",0,i);

      double iLow[i] = iLow("",0,i);

      double range[i] = iHigh[i] - iLow[i];

      int converttopoints[i] = NormalizeDouble(range[i]/Point,Digits);

      int findMaximum[i] = ArrayMaximum(converttopoints[i],WHOLE_ARRAY,0);

   }



   return(Print(findMaximum));

}


Where I have error?

 

Please use the </> button to insert your code.


 

done, sry.

no one can help me?

 
double iHigh[i] = iHigh("",0,i);
double iLow[i] = iLow("",0,i);
return(Print(findMaximum));
  1. Start with code that compiles.
  2. Use a real symbol name or NULL, "" isn't either.
  3. How can you use ArrayMaximum when you are still filling an array?
  4. Don't bump your posts.
 
double range(int bars)
{
   double highest = High[iHighest(_Symbol,_Period,MODE_HIGH,bars)];
   double lowest  = Low[iLowest(_Symbol,_Period,MODE_LOW,bars)];
   return highest-lowest;
}