Draw Rectangle for range

 

Hi guys,

i like to draw a rectangle for the last 5 Bars. Die High of the Rectangle is the Highest High of these Bars and the Low is die lowest Low.

How can i manage this? I'm not sure how to set the high and low.


thanks guys

 
FamWue: I'm not sure how to set the high and low.
void DrawRange(string name, int n=5, int i=0){
   int iLeft = i+n-1,
       iHi = iHighest(NULL, 0, MODE_HIGH, n, i),
       iLo = iLowest( NULL, 0, MODE_LOW,  n, i);
   Rect(name, Time[iLeft],High[iHi],Time[i], Low[iLo], Blue);
}
Rect from my code
void     Rect(string name, datetime T0,double P0, datetime T1,double P1, color clr){
   if(!Show.Objects) return;                    #define WINDOW_MAIN 0
         if(ObjectMove( name, 0, T0, P0 ))      ObjectMove(name, 1, T1, P1);
   else  if(!ObjectCreate( name, OBJ_RECTANGLE, WINDOW_MAIN, T0, P0, T1, P1 ))
      Alert("ObjectCreate(",name,",RECT) failed: ", GetLastError() );
   if(!ObjectSet(name, OBJPROP_color, clr ))    // Allow color change
      Alert("ObjectSet(", name, ",color   ) [3] failed: ", GetLastError());
   string   P0t = PriceToStr(P0);         if(MathAbs(P0 - P1) >= Point)
         P0t = StringConcatenate(P0t, " to ", PriceToStr(P1));
   if(!ObjectSetText(name, P0t, 10))
      Alert("ObjectSetText(",name,") [1] failed: ", GetLastError());
}
Reason: