Problem With Rectangle's Description

 

I made an indicator to draw rectangles with description. The problem is the description is shown inside the rectangles. But if I draw the rectangle manually, the description is shown above the rectangle. I would like to make the indicator to show description above the rectangles. See screenshot below:


Anybody know how to fix this?


Indicator settings are:

DrawAsBackground = true; ShowDescription = true;

//+------------------------------------------------------------------+
//|                                            Breakout Box 1.0b.mq4 |
//|                                             Achmad F. K. Ibrahim |
//|                                                                  |
//+------------------------------------------------------------------+
#property copyright "Achmad F. K. Ibrahim"
#property link      ""

#property indicator_chart_window
//--- input parameters
extern string StartTime = "00:00";
extern string EndTime   = "08:59";
extern color BoxColor   = Yellow;
extern bool DrawAsBackground = false;
extern bool ShowDescription = true;
extern int NumberOfDays=5;

string IndiName = "BreakoutBox";
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
{
//---- indicators
//----
   return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
{
//----
   for(int i=0;i<NumberOfDays;i++)
   {
      string name = StringConcatenate(IndiName, i);
      if(ObjectFind(name)>=0) ObjectDelete(name);
   } 
//----
   return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
{
   for(int i=0;i<NumberOfDays;i++)
   {
      datetime start = StrToTime(StringConcatenate(TimeToStr(iTime(Symbol(), PERIOD_D1, i),TIME_DATE)," ", StartTime));
      
      datetime end = StrToTime(StringConcatenate(TimeToStr(iTime(Symbol(), PERIOD_D1, i),TIME_DATE)," ", EndTime));
      if(end>TimeCurrent()) end = TimeCurrent();
      
      int h = iHighest(Symbol(), 0, MODE_HIGH, iBarShift(Symbol(), 0, start)-iBarShift(Symbol(), 0, end), iBarShift(Symbol(), 0, end));
      int l = iLowest(Symbol(), 0, MODE_LOW, iBarShift(Symbol(), 0, start)-iBarShift(Symbol(), 0, end), iBarShift(Symbol(), 0, end));
      
      string text = StringConcatenate("Lo: ", Low[l], " Hi: ", High[h]);
      
      // object creation
      string name = StringConcatenate(IndiName, "_", i);
      if(ObjectFind(name)<0)
      {
         ObjectCreate(name, OBJ_RECTANGLE, 0, start, Low[l], end, High[h]);
         ObjectSet(name, OBJPROP_BACK, DrawAsBackground);
         ObjectSet(name, OBJPROP_COLOR, BoxColor);
         if(ShowDescription)
            ObjectSetText(name, text);
      }
      else
      {
         ObjectSet(name, OBJPROP_BACK, DrawAsBackground);
         ObjectSet(name, OBJPROP_COLOR, BoxColor);
         ObjectSet(name, OBJPROP_TIME1, start);
         ObjectSet(name, OBJPROP_PRICE1, Low[l]);
         ObjectSet(name, OBJPROP_TIME2, end);
         ObjectSet(name, OBJPROP_PRICE2, High[h]);
         if(ShowDescription)
            ObjectSetText(name, text);
      }
   }
   return(0);
}
//+------------------------------------------------------------------+
 

I didn't know that you could show the rectangles' descriptions on the chart, so I am not sure.

You could try reversing the price parameters

ObjectCreate(name, OBJ_RECTANGLE, 0, start, Low[l], end, High[h]);

//Try changing to 

ObjectCreate(name, OBJ_RECTANGLE, 0, start, High[h], end, Low[l]);