How to locate yesterdays High of the day

KelvinHand

Well-Known Member
#12
Kelvin hand sir or anybody who can
Please help me.
OK. Your wish is granted.
The following code will pinpoint you to the High of the previous day and draw the vertical line.
The rest you figure out yourself.


PHP:
ds = BarsSince(Day() != Ref(Day(), -1));
bVertLine=False;


//===#if 0
//for(i=BarCount-1; i>0; i--)
// if (ds[i]==0) break;

//===#else
bi = BarIndex(); 
start = FirstVisibleValue( bi ); 
end = LastVisibleValue( bi ); 
//===#endif

//**** KH: first we skip backward to the previous day 
for ( i = end; i >= start; i-- ) 
 if (ds[i]==0) break;

//**** KH: Goto the last bar of previous day
i--;

//**** KH: Record the 1st yH at this bar for reference
_y =H[i];
_x = i;

//**** KH: To start from next bar
i--;
for(; i>0; i--)
{
  if(ds[i]>0)
  {

    //**** KH: This is _yH=max(H, _yH)
    if (H[i]>_y)
    {
     _y=H[i];
     _x=i;
    }
  }
  else
  {
    //**** KH: This is the begin of the day, check for _y=Max(H, _y) one more time
    if (H[i]>_y)
    {
     _y=H[i];
     _x=i;
    }

    //**** KH: Set the values here for plotting ***** 
    bVertLine[_x]=true;

    //*** Move to previous last bar and record the high & pos
    i--;
    _y=H[i];
    _x=i;
  }  
}


Plot(bVertLine, "Kelvinhand", colorDarkYellow, styleDashed|styleHistogram|styleOwnScale);
 
Last edited: