Sequential highs or lows

 

Hi all,

I am trying to add a components to my current indicator so that it doesn't return any sequential highs or lows. At the moment, the indicator returns a key high or low based on the 'Get Signal' code, but, I would like to add code which wont allow sequential highs or lows - so if the indicator picks up that the previous value of the indicator was a high it wont allow another high until a low has been returned. Can anyone help me on this or point me in the right direction?

Cheers.

 for(int i=limit; i>=end; i--)
  {

      BuyArrowBuffer[i] = 0;
      SellArrowBuffer[i] = 0;
      TimeI=iTime(Symbol(),0,i);

      int signal=GetSignal(i);
         if (signal<0)
         {
           if(LastSignal<0)
           
           {
           if(value<LastSignalPrice)           continue;
            else ClearPrevBuffer(OP_SELL,i);
           }
           LastSignal=-1;
           LastSignalPrice=High[i]+extrapip*Point;
           SellArrowBuffer[i] = LastSignalPrice;
            string name=Text+DoubleToStr(count,0);
            count++;
            ExtZigzagBuffer[i]=LastSignalPrice;
            Update_ZigZagValues(LastSignalPrice,Time[i]);
            if(DrawLabels)CreateText("APTX_"+name,name,TextColor,Time[i],LastSignalPrice,FontSize);
           UseLong=true;
         }
         if (signal>0)
         {
           if(LastSignal>0)
           {
           if(value>LastSignalPrice)           continue;
            else ClearPrevBuffer(OP_BUY,i);
           }
           LastSignal=1;
           LastSignalPrice=Low[i]-extrapip*Point;
           BuyArrowBuffer[i] = LastSignalPrice;
            name=Text+DoubleToStr(count,0);
            count++;
            ExtZigzagBuffer[i]=LastSignalPrice;
            Update_ZigZagValues(LastSignalPrice,Time[i]);
            if(DrawLabels)CreateText("APTX_"+name,name,TextColor,Time[i],LastSignalPrice,FontSize);
           UseLong=false;
         }
 }
 
 //+------------------------------------------------------------------+
//| Get Signal                                                       |
//+------------------------------------------------------------------+
double value=0;
double LastSignalPrice=0;
int GetSignal (int pos){
if
(
High[pos+2]<High[pos] &&
High[pos+1]<High[pos] &&
High[pos-1]<High[pos] &&
High[pos-2]<High[pos]
)
{
value=High[pos];
return -1;
}
if
(
Low[pos+2]>Low[pos] &&
Low[pos+1]>Low[pos] &&
Low[pos-1]>Low[pos] &&
Low[pos-2]>Low[pos]
)
{
value=Low[pos];
return 1;
}
 return 0;
}
Reason: