Indicator DRAW_FILLING not working peoperly

 
Hi Friends.

I'm trying to create an indicator that shows green fill when price is above a certain level and a red fill when price is below a certain level. But the indicator keeps returning only the red fill.
Code is attached below. Please help me have a look.

Thanks

#property indicator_separate_window
#property indicator_buffers 9
#property indicator_plots   4
#property indicator_level1 30
#property indicator_level2 70
#property indicator_maximum 100
#property indicator_minimum 0

#include <MovingAverages.mqh>

//--- input parameters
input int kPeriod = 14;
input int dPeriod = 3;
input int slowing = 3;
input int TimeZoneOfData = 0;  // Timezone offset in hours
input int BarsToCalculate = 0; // Limit bars to calculate (0 = all)
input ENUM_MA_METHOD method = MODE_SMA;
input ENUM_STO_PRICE price_field = STO_LOWHIGH;

//--- indicator plots
#property indicator_label1  "%K"
#property indicator_type1   DRAW_LINE
#property indicator_color1  clrWhite
#property indicator_width1  2

#property indicator_label2  "%D"
#property indicator_type2   DRAW_LINE
#property indicator_color2  clrRed
#property indicator_width2  2
#property indicator_style2  STYLE_DASH

#property indicator_label3  "WeeklyOpenBG"
#property indicator_type3   DRAW_FILLING
#property indicator_color3  C'47,5,15', C'10,42,15'

#property indicator_label4  "MonthlyOpenBG"
#property indicator_type4   DRAW_FILLING
#property indicator_color4  C'116,13,39', clrMaroon

//--- buffers
double KBuffer[];
double DBuffer[];
double WeeklyTopBuffer[];
double WeeklyBottomBuffer[];
double MonthlyTopBuffer[];
double MonthlyBottomBuffer[];
double WeeklyColorBuffer[];
double MonthlyColorBuffer[];
double TodayOpenBuffer[];


//--- handles
int stoHandle;

//--- tracking open prices
double weeklyOpen = 0;
double monthlyOpen = 0;
datetime lastWeek = 0;
datetime lastMonth = 0;

//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit()
{
   // Main stochastic buffers
   SetIndexBuffer(0, KBuffer, INDICATOR_DATA);
   SetIndexBuffer(1, DBuffer, INDICATOR_DATA);

   // Overlay fill buffers
   SetIndexBuffer(2, WeeklyTopBuffer, INDICATOR_DATA);
   SetIndexBuffer(3, WeeklyBottomBuffer, INDICATOR_DATA);
   SetIndexBuffer(4, MonthlyTopBuffer, INDICATOR_DATA);
   SetIndexBuffer(5, MonthlyBottomBuffer, INDICATOR_DATA);
   
   SetIndexBuffer(6, WeeklyColorBuffer, INDICATOR_COLOR_INDEX);
   SetIndexBuffer(7, MonthlyColorBuffer, INDICATOR_COLOR_INDEX);
   
   SetIndexBuffer(8, TodayOpenBuffer, INDICATOR_CALCULATIONS);
   
   PlotIndexSetInteger(2, PLOT_COLOR_INDEXES, 2);
   PlotIndexSetInteger(3, PLOT_COLOR_INDEXES, 2);

   
   IndicatorSetInteger(INDICATOR_DIGITS, 2);

   // Create Stochastic handle
   stoHandle = iStochastic(_Symbol, _Period, kPeriod, dPeriod, slowing, method, price_field);
   if (stoHandle == INVALID_HANDLE)
   {
      Print("Failed to create Stochastic handle. Error: ", GetLastError());
      return INIT_FAILED;
   }

   return INIT_SUCCEEDED;
}

//+------------------------------------------------------------------+
//| Custom indicator deinitialization                                |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
{
   if (stoHandle != INVALID_HANDLE)
      IndicatorRelease(stoHandle);
}

//+------------------------------------------------------------------+
//| 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[])
{
   if (rates_total < kPeriod + slowing + dPeriod)
      return 0;

   int begin = prev_calculated > 0 ? prev_calculated - 1 : 0;
   int count = rates_total - begin;

   // Fetch stochastic values
   if (CopyBuffer(stoHandle, 0, begin, count, KBuffer) < 0 ||
       CopyBuffer(stoHandle, 1, begin, count, DBuffer) < 0)
   {
      Print("CopyBuffer failed. Error: ", GetLastError());
      return prev_calculated;
   }

   double level_diff = MathAbs(indicator_level1 - indicator_level2);
   double monthlyBottom = indicator_level1 + level_diff * 0.4;
   double monthlyTop = indicator_level2 - level_diff * 0.4;

   for (int i = begin; i < rates_total; i++)
   {
      datetime shifted_time = time[i] + TimeZoneOfData * 3600;
      int shift = iBarShift(_Symbol, PERIOD_W1, shifted_time, false);
      if(shift >= 0)
         TodayOpenBuffer[i] = iOpen(_Symbol, PERIOD_W1, shift);
      else
         TodayOpenBuffer[i] = EMPTY_VALUE;

      // Weekly filling (0–100)
      WeeklyBottomBuffer[i] = 0.0;
      WeeklyTopBuffer[i] = 100.0;
      WeeklyColorBuffer[i] = (close[i] >= weeklyOpen) ? 1 : 0;

      // Monthly filling (centered block)
      MonthlyBottomBuffer[i] = monthlyBottom;
      MonthlyTopBuffer[i] = monthlyTop;
      MonthlyColorBuffer[i] = (close[i] >= monthlyOpen) ? 1 : 0;

   }

   return rates_total;
}
Files:
ind.png  141 kb
 
#property indicator_label3  "WeeklyOpenBG"
#property indicator_type3   DRAW_FILLING
#property indicator_color3  C'47,5,15', C'10,42,15'

#property indicator_label4  "MonthlyOpenBG"
#property indicator_type4   DRAW_FILLING
#property indicator_color4  C'116,13,39', clrMaroon
DRAW_FILLING is not a buffer style. DRAW_FILLING - Indicator Styles in Examples - Custom Indicators - MQL5 Reference - Reference on algorithmic/automated trading language for MetaTrader 5