last swing high or swing low

 

hello, does anyone know of an indicator or mt4 code that can determine the last swing high or low? Something like, for a swing high, finding a "high bar" that has two or more bars on either side below it.


Thanks Brad

 
You mean like fractals ?
 
RaptorUK:
You mean like fractals ?

yes, it looks like fractals is what I want.


Thanks for the tip!

Any suggestions on where I could see some examples of how they are used?

Brad

 
google doesn't work & what abuot this
 
qjol:
google doesn't work & what abuot this

I have the same requirement, I guess zigzag might provide a solution to thie problem.....
 
or roll your own (from my code).
//+------------------------------------------------------------------+
//| Find local extrema                                               |
//+------------------------------------------------------------------+
#define EXAR_LE         true  // Local extream
#define EXAR_RNG        false // fixed range
#define EXAR_LARGEST    +1 // Direction
#define EXAR_SMALLEST   -1 // Defaults to DIR
double   ExtreamArray(double arr[], int length, int iBeg=0,
                                       bool wantLE=false, double d=EMPTY_VALUE){
   return( arr[iExtreamArray(arr, length, iBeg, wantLE, d)] );                }
int      iExtreamArray( double arr[], int length, int iBeg=0,
                                       bool wantLE=false, double d=EMPTY_VALUE){
//double DIR                                 // Import from SetDIR
//#define INF 0x6FFFFFFF // Not quite infinite, Jul 2029, or 1,879,048,191
   if(d == EMPTY_VALUE) d = DIR;
   double   extreama = -d * INF;
   if(length > 0){   // Search iBeg, iBeg+1, ... iBeg+n-1
      int      nBars = ArraySize(arr), iLimit = MathMinI(nBars, iBeg +length);
      for(; iBeg < iLimit; iBeg++){
         double   value = arr[iBeg];
         if((extreama - value)*d < 0.){
            extreama = value; int   iExtreama   = iBeg;
            if(wantLE)              iLimit      = MathMinI(nBars, iBeg +length);
   }  }  }
   else{             // Search iBeg, iBeg-1, ... 0
                                       iLimit   = MathMaxI( -1, iBeg +length);
      for(; iBeg > iLimit; iBeg--){
         value = arr[iBeg];
         if((extreama - value)*d < 0.){
            extreama = value;       iExtreama   = iBeg;
            if(wantLE)                 iLimit   = MathMaxI( -1, iBeg +length);
   }  }  }
   return(iExtreama);
}  // iExtreamArray
int iMRH = iExtreamArray(High, length, 0, EXAR_LE, EXAR_LARGEST),
    iMRL = iExtreamArray(Low,  length, 0, EXAR_LE, EXAR_SMALLEST);
if (iMRH < iMRL) // down trend
Reason: