Download MetaTrader 5
To add comments, please log in or register
Do you want to order an application? Find out how to obtain the desired result
Anton Dmitriev
117
Anton Dmitriev 2015.09.05 02:09 
pretty new to programming.  i imagine this is a pretty common thing, so just wondering if anyone can save me the work. thx.
Keith Watford
Moderator
7984
Keith Watford 2015.09.05 02:21  

Give an example of what you mean to do.

MathMax and MathMin find the max or min of 2 numbers

Anton Dmitriev
117
Anton Dmitriev 2015.09.05 03:03  
i'm looking to identify the highs and lows as the price bounces over and under the mean average.  to the eye, it's easy to see where these highs and lows are, but it might be a bit tough to program such a thing.  retracements (which must be ignored) and double tops (of which i'd simply want the higher of the two) are a couple of examples of problems with identifying these minima and maxima easily.  after that, i'd like to use this function to identify funnels.
Keith Watford
Moderator
7984
Keith Watford 2015.09.05 04:10  

I know that some people use the zig zag indicator to help to identify highs and lows.

price bounces over and under the mean average 

 Is a mean average nastier than a normal average? Or is it just an average average?   :)

whroeder1
13641
whroeder1 2015.09.05 15:20  
/** Finds the index of the maximum local extream
 * i.e.\. moving up hill until you reach the top. */
int   max_extreama(int  window,           ///<[in] Size of a local.
                   int  iEnd,             ///<[in] One past last.
                   int  iBeg=0,           ///<[in] Starting index.
                   int  dir=MODE_ASCEND)  /**<[in] Direction of the search. */{
   if(iEnd == iBeg)  return iEnd;
   if(MODE_ASCEND == dir){
      int      iExtreme = iBeg++;  double   extreme  = High[iExtreme], value;
      int      iLimit   = MathMin(iEnd, iExtreme + window);
      for(; iBeg < iLimit; ++iBeg){
         value = High[iBeg];
         if(extreme < value){
            iExtreme = iBeg;  extreme = value;
            iLimit   = MathMin(iEnd, iExtreme + window);
      }  }
      return iExtreme;
   }
   int      iExtreme = --iEnd;   double extreme = High[iExtreme], value;
   --window;   // iEnd decremented first so window is one smaller.
   int      iLast    = MathMax(iBeg, iExtreme - window);
   while(iEnd > iLast){
      value = High[--iEnd];
      if(extreme < value){
         iExtreme = iEnd;  extreme = value;
         iLast    = MathMax(iBeg, iExtreme - window);
   }  }
   return iExtreme;
}
Anton Dmitriev
117
Anton Dmitriev 2015.09.05 18:33  
thanks for the help guys
/
To add comments, please log in or register