I am trying to produce a weighted moving average on closing stock prices. Their is only one column of data which contains the closing price. I want to have a 7 period weighted moving average of the price. Currently I have to write the following formula:
((7*P1)+(6*P2)+(5*P3)+(4*P4)+(3*P5)+(2*P6)+P7)/28
- where P7 is the price 7 periods ago, P6 is the price 6 periods ago...and so on.
The problem is if I want to look at a 3 period or 21 period weighted moving average I have to re-write the entire formula. Instead I am trying to find a formula that would look at a cell for the number of periods weighted moving average that I want and produce my results.
Is this possible?
Thanks
Bookmarks