help with pivot script

 
i downloaded the pivot history from the web, modified it to show the high and low of the last trading session but it doesnt behave properly, it creates an odd line at the present time and doesnt continue into the future, help appreciated



//+------------------------------------------------------------------+
//|                                                        Pivot.mq4 |
//|                               Copyright ?2004,
//|                                                                  |
//|                                                                  |
//+------------------------------------------------------------------+
#property copyright ""
 
#property indicator_chart_window
//#property indicator_separate_window
#property indicator_buffers 3
#property indicator_color1 Orange
#property indicator_color2 Orange
 
//---- input parameters
 
extern int TZ= 0;
 
//---- buffers
double LHighBuffer[];
double LLowBuffer[];
int fontsize=10;
double LastHigh,LastLow,x,LHigh,LLow;
 
//+------------------------------------------------------------------+
//| Custor indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//---- TODO: add your code here
 
   ObjectDelete("High");
   ObjectDelete("Low");
 
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
   string short_name;
 
 
//---- indicator line
   SetIndexStyle(0,DRAW_LINE,0,1,Orange);
   SetIndexStyle(1,DRAW_LINE,0,1,Orange);
  
   SetIndexBuffer(0,LHighBuffer);
   SetIndexBuffer(1,LLowBuffer);
 
 
//---- name for DataWindow and indicator subwindow label
   short_name="high low";
   IndicatorShortName(short_name);
   SetIndexLabel(0,short_name);
 
//----
   SetIndexDrawBegin(0,1);
   SetIndexDrawBegin(1,1);
//----
 
 
//----
   return(0);
  }
 
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
 
  {
   int    counted_bars=IndicatorCounted();
 
   int limit, i;
//---- indicator calculation
if (counted_bars==0)
{
   x=Period();
   if (x>240) return(-1);
   ObjectCreate("High", OBJ_TEXT, 0, 0, 0);
   ObjectSetText("High", "      High",fontsize,"Arial",Red);
   ObjectCreate("Low", OBJ_TEXT, 0, 0, 0);
   ObjectSetText("Low", "      Low",fontsize,"Arial",Red);
}
   if(counted_bars<0) return(-1);
//---- last counted bar will be recounted
 if(counted_bars>0) counted_bars--;
   limit=(Bars-counted_bars)-1;
 
 
//if (Volume[0]<=1 || LHigh<=0)
{
for (i=limit; i>=0;i--)
{ 
   if (High[i+1]>LastHigh) LastHigh=High[i+1];
   if (Low[i+1]<LastLow) LastLow=Low[i+1];
   
 // if (TimeDay(Time[i]-TZ*3600)!=TimeDay(Time[i+1]-TZ*3600))
 if(TimeDay(Time[i]) != TimeDay(Time[i+1]))
   { 
 
 
 
   double LHigh = LastHigh;
   double LLow = LastLow;
    LastLow=Close[i]; LastHigh=Close[i];
 
      ObjectMove("High", 0, Time[i],LHigh);
      ObjectMove("Low", 0, Time[i],LLow);
 
   }
    LHighBuffer[i]=LHigh;
   LLowBuffer[i]=LLow;
  
 
}
}
//----
   return(0);
  }
//+------------------------------------------------------------------+
 
nvm, figured it out
Reason: