How to find the first swing high and low of a range

Back to topics list To post a new topic, please log in or register
avatar
29
remix919 2016.01.09 22:53
 

Pretty much as the title states, how can I find the first swing high and swing low of a bigger range?

    

avatar
1111
Ovo 2016.01.10 07:46 #
 
remix919:

Pretty much as the title states, how can I find the first swing high and swing low of a bigger range?

    

you cannot find a swing, unless you exactly express, what you consider to be a swing.
avatar
13012
WHRoeder 2016.01.10 14:09 #
 
Think about
//+------------------------------------------------------------------+
//| Find a local extreme bar value                                   |
//+------------------------------------------------------------------+
int MaximalBar(int length, int start=0, int TF=0, double d=INF){
   if (d>=INF) d=DIR;
   if (Bars-start < length)   length = Bars - start;
   if (d>0)    return( Highest(NULL, TF, MODE_HIGH, length, start) );
   else     return(  Lowest(NULL, TF, MODE_LOW,  length, start) );
}
int LocalExtreme(int WS, int first=0, int TF=0, double d=INF){
   while(true){                                             int
      firstPrev   = first;
      first    = MaximalBar(WS, first, TF, d);
      if (first == firstPrev)    return(first);
   }
   /*NOTREACHED*/
}  // LocalExtreme
double LastFractal(int WS, int TF=0, double d=INF){
   for (int shift=1; shift<Bars; shift++){
      int LE = LocalExtreme(WS, shift, TF, d);
      if (LE >= shift+2)   return (LE);
   }
   return(Bars-1);
}

avatar
29
remix919 2016.01.10 14:46 #
 
Ovo:
you cannot find a swing, unless you exactly express, what you consider to be a swing.
The FIRST swing high and swing low in this case would simply be the first high and low fractal within a range.
avatar
29
remix919 2016.01.10 14:47 #
 
WHRoeder:
Think about
Thanks WHRoeder, I'll play around with this and see if I can figure it out :)
Back to topics list  

To add comments, please log in or register