//   Last Bar v1.0  ( current H1 bar/candle )

#property indicator_chart_window

input color UPcol = C'0,150,0';
input color DOWNcol = C'220,0,0';
input color BarCol = Gray;

extern int Shift = -11;
extern int Width = 10;

datetime curTime;

double H1_high, H1_low, H1_open, H1_close;

int xUnit,shift,width;

//-----------------------------------------
int init()
  {
   xUnit   = Period() * 60;
   shift   = Shift * xUnit;
   width   = Width * xUnit;
  
   return(0);
  }

int deinit()
  {
  
  ObjectDelete("U_T");  
  ObjectDelete("O_C"); 
  ObjectDelete("D_T"); 

  return(0);
  }
//----------------------------------------
int start()
  {
  
   H1_high=iHigh(NULL, PERIOD_H1,0); 
   H1_low=iLow(NULL, PERIOD_H1,0);     
   H1_open=iOpen(NULL, PERIOD_H1,0); 
   H1_close=iClose(NULL, PERIOD_H1,0);  
      
   color Col;
   
   if (H1_close > H1_open)Col= UPcol;
   if (H1_close < H1_open)Col= DOWNcol;
      
   curTime = Time[0];    
      
   ObjectDelete(0,"U_T");
   ObjectCreate(0,"U_T",OBJ_RECTANGLE,0,0,0,0,0);
   ObjectSet("U_T", OBJPROP_TIME1,  curTime+shift);
   ObjectSet("U_T", OBJPROP_TIME2,  curTime+shift+width);
   ObjectSet("U_T", OBJPROP_PRICE1, H1_high );
   if (H1_close > H1_open) ObjectSet("U_T", OBJPROP_PRICE2, H1_close );
   if (H1_close < H1_open) ObjectSet("U_T", OBJPROP_PRICE2, H1_open );
   ObjectSet("U_T", OBJPROP_COLOR,  BarCol);
   
   ObjectDelete(0,"O_C");
   ObjectCreate(0,"O_C",OBJ_RECTANGLE,0,0,0,0,0);
   ObjectSet("O_C", OBJPROP_TIME1,  curTime+shift);
   ObjectSet("O_C", OBJPROP_TIME2,  curTime+shift+width);
   ObjectSet("O_C", OBJPROP_PRICE1, H1_open );
   ObjectSet("O_C", OBJPROP_PRICE2, H1_close );
   ObjectSet("O_C", OBJPROP_COLOR,  Col);
   
   ObjectDelete(0,"D_T");
   ObjectCreate(0,"D_T",OBJ_RECTANGLE,0,0,0,0,0);
   ObjectSet("D_T", OBJPROP_TIME1,  curTime+shift);
   ObjectSet("D_T", OBJPROP_TIME2,  curTime+shift+width);
   ObjectSet("D_T", OBJPROP_PRICE1, H1_low );
   if (H1_close > H1_open) ObjectSet("D_T", OBJPROP_PRICE2, H1_open );
   if (H1_close < H1_open) ObjectSet("D_T", OBJPROP_PRICE2, H1_close );
   ObjectSet("D_T", OBJPROP_COLOR,  BarCol);
   
  return(0); 
  }