//+------------------------------------------------------------------+
//|                                            Draw BAR_HILOZONE.mq4 |
//|                                                                  |
//|                                                                  |
//+------------------------------------------------------------------+
#property copyright ""
#property link      ""

#property show_inputs

input int             Offset_Right = 9;
input color           High_Color   = clrRed;
input color           Low_Color    = clrDodgerBlue;
input ENUM_LINE_STYLE Lines_Style  = STYLE_SOLID;
input int             Lines_Width  = 2;
input bool            Show_Info    = false;

//+------------------------------------------------------------------+
//| script program start function                                    |
//+------------------------------------------------------------------+
int start()
  {
//----
//****DON'T TOUCH BELOW HERE****
datetime time=WindowTimeOnDropped();

int time_shift=iBarShift(Symbol(),0,time,true);

double high_time=High[time_shift];
double low_time=Low[time_shift];
double close_price=Close[time_shift];
double open_price=Open[time_shift];


datetime thefuture=time+Offset_Right*_Period*60; //iTime(Symbol(),1440,0)+1440*60; //iTime(Symbol(),0,0)+31536000; // 
datetime lastbar= time;//time-Period()*18*60;

string period;
if(Period() == 43200) {period = "MN"; int BO_Style=Lines_Style; int BO_Width=Lines_Width;} 
if(Period() == 10080) {period = "W1"; BO_Style=Lines_Style; BO_Width=Lines_Width;} 
if(Period() == 1440) {period = "D1"; BO_Style=Lines_Style; BO_Width=Lines_Width;}
if(Period() == 240) {period = "H4"; BO_Style=Lines_Style; BO_Width=Lines_Width;}
if(Period() == 60) {period = "H1"; BO_Style=Lines_Style; BO_Width=Lines_Width;}   
if(Period() == 30) {period = "M30"; BO_Style=Lines_Style; BO_Width=Lines_Width;} 
if(Period() == 15) {period = "M15"; BO_Style=Lines_Style; BO_Width=Lines_Width;} 
if(Period() == 5) {period = "M5"; BO_Style=Lines_Style; BO_Width=Lines_Width;} 
if(Period() == 1) {period = "M1"; BO_Style=Lines_Style; BO_Width=Lines_Width;} 

ObjectDelete("High_Line"+period+"_"+time);
ObjectCreate("High_Line"+period+"_"+time,OBJ_TREND,0,lastbar,high_time,thefuture,high_time);
ObjectSet("High_Line"+period+"_"+time,OBJPROP_COLOR,High_Color);
ObjectSet("High_Line"+period+"_"+time,OBJPROP_STYLE,BO_Style);
ObjectSet("High_Line"+period+"_"+time,OBJPROP_WIDTH,BO_Width);
ObjectSet("High_Line"+period+"_"+time,OBJPROP_BACK,false);
ObjectSet("High_Line"+period+"_"+time,OBJPROP_RAY,false);
if(Show_Info)
ObjectSetText("High_Line"+period+"_"+time,period+" High ", 8, "Berlin Sans FB", clrWhite);

ObjectDelete("Low_Line"+period+"_"+time);
ObjectCreate("Low_Line"+period+"_"+time,OBJ_TREND,0,lastbar,low_time,thefuture,low_time);
ObjectSet("Low_Line"+period+"_"+time,OBJPROP_COLOR,Low_Color);
ObjectSet("Low_Line"+period+"_"+time,OBJPROP_STYLE,BO_Style);
ObjectSet("Low_Line"+period+"_"+time,OBJPROP_WIDTH,BO_Width);
ObjectSet("Low_Line"+period+"_"+time,OBJPROP_BACK,false);
ObjectSet("Low_Line"+period+"_"+time,OBJPROP_RAY,false);
if(Show_Info)
ObjectSetText("Low_Line"+period+"_"+time,period+" Low ", 8, "Berlin Sans FB", clrWhite);
//----
   return(0);
  }
//+------------------------------------------------------------------+