Finding Prevoius High/low(Little Help Needed Here)

 

Hi Every body, little help needed just

im usign this to find a high/low


iHighest(NULL,0,MODE_HIGH,BarsHistoryCount,1) or ....


any one have any idea to find a better high/low (previously)?

BarsHistoryCount is always changing, i need a better way to find previous high/low specialy on TF-5min

help plz,

 

What you're looking for is perhaps something like the following Peak and Dip functions, which deliver a highest or lowest over a range of nStart +/- nWidth, up to a maximum of nLookbck bars, or -1 if not found

double Peak(int nWidth, int nLookback, int nStart)
{
  for (int i=nStart+nWidth ; i<nStart+nLookback ; i++)
  {
    int nHighest = iHighest(Symbol(),0,MODE_HIGH,i,nStart);
    if (nHighest >= nStart+nWidth && nHighest <= i-nWidth) return(High[nHighest]);
  }
  return(-1);
}


double Dip(int nWidth, int nLookback, int nStart)
{
  for (int i=nStart+nWidth ; i<nStart+nLookback ; i++)
  {
    int nLowest = iLowest(Symbol(),0,MODE_LOW,i,nStart);
    if (nLowest >= nStart+nWidth && nLowest <= i-nWidth) return(Low[nLowest]);
  }
  return(-1);
}

Paul

http://paulsfxrandomwalk.blogspot.com/

Reason: