I posted this question on the excel vba forum and haven't had too much of a response, but there is someone that thinks my problem can be done in excel. Therefore, I figured someone on this forum may be able to help out. Here it is:
I am unsure of where to start, so here's my problem:
Here is a sample of the beginning data:
Date Price
5/1/2012 122.12
5/2/2012 121.89
5/3/2012 123.27
5/4/2012 121.48
5/7/2012 121.79
5/8/2012 123.35
5/9/2012 124.47
5/10/2012 125.2
5/11/2012 123.29
5/14/2012 122.57
5/15/2012 120.4
5/16/2012 119.62
5/17/2012 118.23
5/18/2012 117.17
5/21/2012 119.11
5/22/2012 120.3
5/23/2012 125
5/24/2012 125.52
5/25/2012 126.43
5/29/2012 129.54
5/30/2012 128.81
5/31/2012 130.25
I want the program/solver/formula (whatever i need) to start with the earliest date (5/1/2012) and take the beginning price (122.12) and see if there is a higher value in the next 4 (business) days.
If there is a higher value, then the program should move to that date. This pattern will continue until there is not a higher value in the next 4 (business) days.
If there is not a higher value, the program needs to calculate a slope test (y2 -y1)/(x2-x1) for each value for the next 14 (business) days.
For example, the slope for 5/10 and 5/11 is -1.91. The program should only care about slopes =< .02 and => -.02. Therefore, the program would move from price to price until it stopped on 5/23 where the slope between 5/10 and 5/23 is .02.
Finally, once it has found a slope that meets the parameters, it should output--in text--the dates and prices used in finding the slope, and the dates and prices of the next 3 days after the value of y2, x2 (5/23).
For example:
the output should be:
5/10/2012 125.2
5/23/2012 125
5/24/2012 125.52
5/25/2012 126.43
5/29/2012 129.54
Any help would be greatly appreciated; I've been stuck for days.
Help!.xlsx
I've attached a workbook
Thank you!
Bookmarks