DRAW_FILLING Problems

 

Hello Friends

Please I'm working on an indicator that is supposed to draw_filling on the chart just like a rectangle. Its not working.

I tried rectangle create with thesame calculations and it works perfectly.

Please help me look into my code

//+------------------------------------------------------------------+
//|                                                 Learning BUY.mq5 |
//|                                Copyright 2022, Asikhemhen Osazee |
//|                                                         https:// |
//+------------------------------------------------------------------+
#property copyright "Copyright 2022, Asikhemhen Osazee"
#property link      "https://"
#property version   "1.00"
#property indicator_chart_window
#property indicator_buffers 4
#property indicator_plots   2

#property indicator_label1  "BUY Down"
#property indicator_type1   DRAW_FILLING
#property indicator_color1  clrRed,clrRed
#property indicator_width1  1

#property indicator_label2  "BUY Up"
#property indicator_type2   DRAW_FILLING
#property indicator_color2  clrBlue, clrBlue
#property indicator_width2  1

double BearishUpper[];
double BearishLower[];
double BullishUpper[];
double BullishLower[];
double BUY[];

string namee = "KKK";
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit()
  {
   SetIndexBuffer(0,BearishUpper,INDICATOR_DATA);
   SetIndexBuffer(1,BearishLower,INDICATOR_DATA);
   SetIndexBuffer(2,BullishUpper,INDICATOR_DATA);
   SetIndexBuffer(3,BullishLower,INDICATOR_DATA);

   return(INIT_SUCCEEDED);
  }
  
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
  {
      for(int i=ObjectsTotal(0)-1;i>=0;i--)
         {
            //if(StringFind(ObjectName(0, i), namee, 0) >=0)
              {
                 ObjectDelete(0, ObjectName(0, i));
              }
         }
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int OnCalculate(const int rates_total,
                const int prev_calculated,
                const datetime &time[],
                const double &open[],
                const double &high[],
                const double &low[],
                const double &close[],
                const long &tick_volume[],
                const long &volume[],
                const int &spread[])
  {

   
   int z=0;
   for(int i=0;i<rates_total;i++)
     {
        BearishLower[i] = 0;
        BearishUpper[i] = 0;    
        BullishLower[i] = 0;
        BullishUpper[i] = 0;      
        
        if (bearishBUY(i))
           {     
              BearishUpper[i]   = Low(i+2);
              BearishLower[i]   = High(i);
              createRectangle(namee+(string)i, Time(i+3), BearishUpper[i], Time(i-3), BearishLower[i], clrRed);
           }
        if (bullishBUY(i))
           {     
              BullishUpper[i]   = Low(i);
              BullishLower[i]   = High(i+2);
              createRectangle(namee+(string)i, Time(i+3), BullishUpper[i], Time(i-3), BullishLower[i], clrBlue);
           }
     }



   
//--- return value of prev_calculated for next call
   return(rates_total);
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
bool bearishBUY(int shift)
{
   bool b=false;
   b = (Low(shift)<Low(shift+2) && Low(shift)<Low(shift+1) && High(shift)<Low(shift+2) && High(shift+1)<High(shift+2) && High(shift+1)>Low(shift+2))    ?  true    :  false;   
   return b;
}
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
bool bullishBUY(int shift)
{
   bool b=false;
   b = (High(shift)>High(shift+2) && High(shift)>High(shift+1) && Low(shift)>High(shift+2) && Low(shift+1)>Low(shift+2) && Low(shift+1)<High(shift+2))    ?  true    :  false;   
   return b;
}
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
double  Open(int shift)
{
   return iOpen(Symbol(), PERIOD_CURRENT, shift);
}
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
double  High(int shift)
{
   return iHigh(Symbol(), PERIOD_CURRENT, shift);
}
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
double  Low(int shift)
{
   return iLow(Symbol(), PERIOD_CURRENT, shift);
}
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
double  Close(int shift)
{
   return iClose(Symbol(), PERIOD_CURRENT, shift);
}
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
datetime  Time(int shift)
{
   return iTime(Symbol(), PERIOD_CURRENT, shift);
}
 



This is how I want the indicator to look like

 

You do not even need buffers as I see in your code.