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
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
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