How to make this pivot indicator to plot only HLINES for the month

 

Attached is the source of this indicator. Currently it makes use of ObjectMove to continuously plot the pivot levels. I'm trying to modify this indi so that it plots HLINES (Horizontal lines) for the pivot levels for the past month..

I believe I have to change or replace the ObjectMove instances.. could someone advice on how to do this?

Here's how I want the pivot levels to be displayed: https://www.mql5.com/en/charts


//+------------------------------------------------------------------+
//|                                                    Monthly Pivot |
//|                                    Copyright © 2006, Profitrader |
//|                                    Coded/Verified by Profitrader |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2006, Profitrader."
#property link      "profitrader@inbox.ru"

#property indicator_chart_window
#property indicator_buffers 7
#property indicator_color1 DarkSlateGray
#property indicator_color2 YellowGreen
#property indicator_width2 1
#property indicator_color3 Tomato
#property indicator_width3 1
#property indicator_color4 YellowGreen
#property indicator_width4 2
#property indicator_color5 Tomato
#property indicator_width5 2
//---- buffers
double PBuffer[];
double S1Buffer[];
double R1Buffer[];
double S2Buffer[];
double R2Buffer[];


double P,S1,R1,S2,R2,last_month_high,last_month_low,last_month_close,this_month_open;
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
   SetIndexBuffer(0,PBuffer);
   SetIndexBuffer(1,S1Buffer);
   SetIndexBuffer(2,R1Buffer);
   SetIndexBuffer(3,S2Buffer);
   SetIndexBuffer(4,R2Buffer);
   SetIndexStyle(0,DRAW_LINE,0,1);
   SetIndexStyle(1,DRAW_LINE,0,2);
   SetIndexStyle(2,DRAW_LINE,0,2);
   SetIndexStyle(3,DRAW_LINE,0,3);
   SetIndexStyle(4,DRAW_LINE,0,3);
   SetIndexLabel(0,"Monthly Pivot Point");
   SetIndexLabel(1,"Monthly Support 1");
   SetIndexLabel(2,"Monthly Resistant 1");
   SetIndexLabel(3,"Monthly Support 2");
   SetIndexLabel(4,"Monthly Resistant 2");
   return(0);
  }
//+------------------------------------------------------------------+
//| Custor indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
   ObjectDelete("Monthly Pivot");
   ObjectDelete("Monthly Sup1");
   ObjectDelete("Monthly Res1");
   ObjectDelete("Monthly Sup2");
   ObjectDelete("Monthly Res2");  
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
   int i,counted_bars=IndicatorCounted();
//---- check for possible errors
   if(counted_bars<0) return(-1);
//---- last counted bar will be recounted
   if(counted_bars>0) counted_bars--;  
   int limit=Bars-counted_bars;
   
   if(Period()>PERIOD_D1) return(-1);
   if(counted_bars==0)
     {
      ObjectCreate("Monthly Pivot",OBJ_TEXT,0,0,0);
      ObjectSetText("Monthly Pivot","                            Pivot",8,"Arial",DarkSlateGray);
      ObjectCreate("Monthly Sup1",OBJ_TEXT,0,0,0);
      ObjectSetText("Monthly Sup1","        S1",8,"Arial",Green);
      ObjectCreate("Monthly Res1",OBJ_TEXT,0,0,0);
      ObjectSetText("Monthly Res1","        R1",8,"Arial",Tomato);
      ObjectCreate("Monthly Sup2",OBJ_TEXT,0,0,0);
      ObjectSetText("Monthly Sup2","        S2",8,"Arial",Green);
      ObjectCreate("Monthly Res2",OBJ_TEXT,0,0,0);
      ObjectSetText("Monthly Res2","        R2",8,"Arial",Tomato);
     }
   for(i=limit-1; i>=0; i--)
      {
       // 1sts Days of Month
            if(TimeDay(Time[i])<=3 && TimeDay(Time[i+1])>=26)
              {
                    last_month_close=Close[i+1];
                    this_month_open=Open[i];            
                    P=(last_month_high+last_month_low+last_month_close)/3;
          R1=(2*P)-last_month_low;
          S1=(2*P)-last_month_high;
          R2=P+(last_month_high-last_month_low);
          S2=P-(last_month_high-last_month_low); 
          ObjectMove("Monthly Pivot",0,Time[i],P);
          ObjectMove("Monthly Sup1",0,Time[i],S1);
          ObjectMove("Monthly Res1",0,Time[i],R1);
          ObjectMove("Monthly Sup2",0,Time[i],S2);
          ObjectMove("Monthly Res2",0,Time[i],R2);
          last_month_low=Low[i];
          last_month_high=High[i];
         }       
       last_month_low=MathMin(last_month_low,Low[i]);   
       last_month_high=MathMax(last_month_high,High[i]);
       PBuffer[i]=P;
       S1Buffer[i]=S1;
       R1Buffer[i]=R1;
       S2Buffer[i]=S2;
       R2Buffer[i]=R2;
      }
//----
   return(0);
  }
//+------------------------------------------------------------------+
 
jb1981: Attached is the source of this indicator. ... change or replace the ObjectMove instances.. could someone advice on how to do this?
Nothing attached. Stop using objects and use your buffers. Fix the indicator so it works on ANY timeframe
Your code
   for(i=limit-1; i>=0; i--)
      {
       // 1sts Days of Month
            if(TimeDay(Time[i])<=3 && TimeDay(Time[i+1])>=26)
              {
                    last_month_close=Close[i+1];   // Wrong only on a D1 chart
                    this_month_open=Open[i];       // and when i=First of the month
                    P=(last_month_high+last_month_low+last_month_close)/3;
          R1=(2*P)-last_month_low;
          S1=(2*P)-last_month_high;
          R2=P+(last_month_high-last_month_low);
          S2=P-(last_month_high-last_month_low); 
          ObjectMove("Monthly Pivot",0,Time[i],P); // Stop using objects, use your buffers
          ObjectMove("Monthly Sup1",0,Time[i],S1);
          ObjectMove("Monthly Res1",0,Time[i],R1);
          ObjectMove("Monthly Sup2",0,Time[i],S2);
          ObjectMove("Monthly Res2",0,Time[i],R2);
          last_month_low=Low[i];                 // False that's the last day of the
          last_month_high=High[i];               // month if you fix the above problem.
         }       
       last_month_low=MathMin(last_month_low,Low[i]);   
       last_month_high=MathMax(last_month_high,High[i]);
       PBuffer[i]=P;
Monthly pivot on any time frame
datetime monthStarts =  iTime(NULL, PERIOD_MN1,0);
last_month_close     = iClose(NULL, PERIOD_MN1, 1);
this_month_open      =  iOpen(NULL, PERIOD_MN1, 0);
last_month_low       =   iLow(NULL, PERIOD_MN1, 1);
last_month_high      =  iHigh(NULL, PERIOD_MN1, 1);
P= ..
:
int iMNlimit = iBarShift(NULL,0, monthStarts) + 1; if(limit>iMNlimit) limit=iMNlimit;
for(i=limit-1; i>=0; i--)
   PBuffer[iChart] = P;
   :
}