//+------------------------------------------------------------------+
//|PMLPMH_V1.mq4                                                       |
//|Programmed by Me                                                  |
//+------------------------------------------------------------------+

#property indicator_chart_window

extern int Shift_PrevMonthly_LABEL = 20;
extern int Shift_Num_Bars = 32;
extern int PrevMonthly_LineStyle = 2;
extern color line_color_PrevMonthlyUPPER = clrGold;
extern color line_color_PrevMonthlyLOWER = clrBlue;

double MHigh, MLow;
datetime lastTime_TF;
 
void ObjDel()
{
    ObjectDelete("PreviousMonthlyHi");
    ObjectDelete("PreviousMonthlyLo");
    ObjectDelete("PMHILO");
    ObjectDelete("PMHILO1");
}
                  
int init()
{
    IndicatorShortName("PMLPMH_V1");
    
    Comment("");
    ObjDel();
    
    MHigh = iHigh(NULL, PERIOD_MN1, 1);
    MLow = iLow(NULL, PERIOD_MN1, 1);
    
    return(0);
}
   
   
int deinit()
{  
    Comment("");
    ObjDel();
    
    return(0);
}

int start()
{
    datetime tickTime_TF;
    
    tickTime_TF = iTime(NULL, PERIOD_M1, 0);
    if (tickTime_TF != lastTime_TF) 
    {    
	    lastTime_TF = tickTime_TF;
	    
	    ObjDel();
        PlotLineDLY("PreviousMonthlyHi", MHigh, line_color_PrevMonthlyUPPER, 0);
        PlotLineDLY("PreviousMonthlyLo", MLow, line_color_PrevMonthlyLOWER, 0);
      
        if (ObjectFind("PMHILO") != 0)
        {
            ObjectCreate("PMHILO", OBJ_TEXT, 0, Time[Shift_PrevMonthly_LABEL], MHigh);  
            ObjectSetText("PMHILO", "PMH", 8, "Arial", line_color_PrevMonthlyUPPER);
        }
        else
        {  
            ObjectMove("PMHILO", 0, Time[Shift_PrevMonthly_LABEL], MHigh);
        }
      
        if (ObjectFind("PMHILO1") != 0)
        {
            ObjectCreate("PMHILO1", OBJ_TEXT, 0, Time[Shift_PrevMonthly_LABEL], MLow);
            ObjectSetText("PMHILO1", "PML", 8, "Arial", line_color_PrevMonthlyLOWER);
        }
        else
        {  
            ObjectMove("PMHILO1", 0, Time[Shift_PrevMonthly_LABEL], MLow);
        }
    }
  
    return(0);
}

  
void PlotLineDLY(string dayname, double value, double col, double style)
{
    ObjectCreate(dayname, OBJ_TREND, 0, Time[Shift_Num_Bars], value, Time[0], value);
    ObjectSet(dayname, OBJPROP_WIDTH, 1);
    ObjectSet(dayname, OBJPROP_STYLE, PrevMonthly_LineStyle );
    ObjectSet(dayname, OBJPROP_RAY, false);
    ObjectSet(dayname, OBJPROP_BACK, true);
    ObjectSet(dayname, OBJPROP_COLOR, col);
}
  
         


