You will need several hundred data points (daily closes, average temperatures, gallons of gin, whatever) to achieve a comfort level with the output.
There are a many ways to get the data sets you need to seed your program and a number of ways to keep them up to date once you have the beginning set. I use Yahoo finance and their historical data function to get large quantities of data quickly. I download these data points to an Excel spreadsheet. Then I update my spreads daily by hand. I could buy an automated update but I’m not frugal – I’m cheap.
Once I get a sequence of closing prices I normalize the list. By this I mean that I divide the most current value by the average of the last 20 values on the list. That gives me a percentage value for the day that reflects the relationship of that data point to all the others of the last 20 days. Now this is important – do not include the current day in the average – it is the last 20 days - not today and the last 19 days. I have found that by normalizing prices in this manner and then smoothing the output I can compare all manners of stocks, indices and so on. As long as it is a sequential data set it can be compared – sometimes it isn’t as crisp as you might like but most often it describes what you need to know. I settled on 20 days because my testing and other research suggests that the market operates on a 20-day cycle.
I then derive a 4-period exponential moving average of the list of normalized prices. The way this is done is to go down into your data set several hundred items to a logical starting place and get a simple moving average of 20 normalized prices. Then you find your exponents.
You derive exponent 1 by taking the length of the desired average, adding 1 to it and dividing the sum into 2.
2/(length+1) = 2/(4+1) = .4
Exponent 2 is simply:
1 – exponent 1 = 1 - .4 = .6
Then starting with the original simple moving average you multiply the next normalized price by exponent 1 and add that to your moving average multiplied by exponent 2. In other words you are taking part of the old and part of the new to form the next average in your list.
Next normalized price on the list = 1.0004351
Last moving average on the list = 1.0235303
Find (1.0004351 * .4) and add the result to (1.0235303 * .6) and that will get you 1.0142922.
If you are still with me good for you – if not – I understand.
At the end of this process you have a list of exponential moving averages going back into however long you wanted it to go. I have some that are thousands and thousands of entries long. It is, after all, the basis of Marlyn’s amazing Curve. And allows you to do these kinds of comparisons –
Now we are ready to devise the NewMoMo indicator. Using the Excel min/max capability I first find the maximum of the last 5 days of the exponential averages and I record them in a separate column. Next I find the minimum of the last 5 days of EA and record them in a second column. I do this for however many entries I have in my exponential average list. Then I simply subtract the max column from the exponential average column and put that in a column by itself. I do the same for the min column and put that in a column by itself. Note that the max column will either be a negative number or 0 and the min column will either be a positive number or 0.
Then using the charting capability in Excel - I output a chart of NewMoMo from the two columns I just formed of any length I desire.
This shows two years of DIA using weekly data. You can see on the weekly basis we haven't rolled over going up yet and this, in fact reflects that flattening that I've been talking about for the past several months. Once the bar turns up we will probably have many weeks of recovery ahead of us. Of course nothing is certain and the next bar could be down as well as up but that remains to be seen next week.
Here is a screen cap of the top 20 lines or so of one of the spreadsheets I use with the annotation of the formula.
To test this I use a spreadsheet capability that permits me to enter a bar number from the NewMoMo chart and then I can see how the next several days, weeks, months react given a positive or negative bar of length x . The output of that looks like this –
Well that's probably as clear as mud - it isn't easy describing stuff you do automatically but when I began this quest I started with an empty spreadsheet and an empty mind and look what obtained. Imagination - it is the stuff of magic.