Download MetaTrader 5
To add comments, please log in or register
They are making profit already using Freelance service. You can join them!
remix919
85
remix919 2016.01.09 21:53 

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

    

Ovo Cz
2954
Ovo Cz 2016.01.10 06: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.
whroeder1
13590
whroeder1 2016.01.10 13: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);
}
remix919
85
remix919 2016.01.10 13: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.
remix919
85
remix919 2016.01.10 13:47  
WHRoeder:
Think about
Thanks WHRoeder, I'll play around with this and see if I can figure it out :)
/
To add comments, please log in or register