In a moving window only two points change: the first one, which gets dropped, and the last one, which gets added. Unless one of those two points is Min or Max, the Min and Max remain the same. So, the comparisons need to be run on only those two points.
If the dropped point is neither, old min and max remain. If the dropped point is either min or max and the new point is not bigger or smaller than that, then the new min or max needs to be found. ________________________________ From: nonlinear5 <[email protected]> To: [email protected] Sent: Thu, December 23, 2010 9:19:13 AM Subject: Re: [JBookTrader] peak and reversal detection -> help needed >Min and max will be computationally expensive if re-computed on the entire >window each time. Fortunately, this is not necessary. As each new tick >arrives, >it is compared to Min and to Max. If it is bigger / smaller than Max/Min, it >replaces them. This is O(1) operation as well. > But in a moving window, the min/max may drop. I don't understand how you would maintain the min/max in O(1) time. -- You received this message because you are subscribed to the Google Groups "JBookTrader" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/jbooktrader?hl=en. -- You received this message because you are subscribed to the Google Groups "JBookTrader" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/jbooktrader?hl=en.
