LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #7   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 905
Default Conditional Sum - Moving Average

"Elton Law" wrote:
I slightly change to this [....]
=IF(COUNT(OFFSET(B3,0,0,1,$B$1))=$B$1,
AVERAGE(OFFSET(B3,0,0,1,$B$1)),"")


Good pick up! The constant 3 was definitely a mistake, not what I intended.


----- original message -----

"Elton Law" wrote in message
...
Hi Joe,
Thanks for help.
Get exactly what I want ...

I slightly change to this .... and I can work out the SMA more easily.

=IF(COUNT(OFFSET(B3,0,0,1,$B$1))=$B$1,AVERAGE(OFFS ET(B3,0,0,1,$B$1)),"")
Thanks so much for help ....



"Joe User" wrote:

"Elton Law" wrote:
If I type 3 in B1, then it can calculate the 3-day simple moving
average.
In this case it is 1.6833
If I type 5 in B1, then it can work out 5-day simple moving average.
In this case, it is 1.690
If I type 6 in B1, then it can work out 6-day simple moving average.
In this case, it is 1.6450

Starting point is the latest day which is 26 Mar (in this case) .


To do just what you ask for:

=AVERAGE(OFFSET(B3,0,0,1, B1))

To make that a leading simple moving average starting in C1 using data
starting in B3, my first formula should work with the following change:

=IF(COUNT(OFFSET(B3,0,0,1,$B$1))=3,AVERAGE(OFFSET( B3,0,0,1,$B$1)),"")

Copy across for a moving average.

I started the moving average with C3 because I usually put the moving
average above the beginning (for leading) or ending (for trailing) data
point
for the period. Since you put the period length in B1, I thought the
leading
moving average would start with the data in C3.

My previous formula for the trailing SMA does use data starting in B3.
The
reference to D3 (for the formula in C1) is a trick to avoid having to
write
$B$1-1 and -$B$1+1.


----- original message -----

"Elton Law" wrote:

Hi Expert,
I am so sorry.
I did not make the question clearly.

Should be this.

A B C D E F G
3 1.6833
26-Mar 24-Mar 23-Mar 22-Mar 21-Mar 20-Mar
Stock 1.7 1.6 1.75 1.63 1.77 1.42

B2 to G2 is date 26 Mar to 20 Mar
B3 to G3 is Price.

If I type 3 in B1, then it can calculate the 3-day simple moving
average.
In this case it is 1.6833
If I type 5 in B1, then it can work out 5-day simple moving average.
In this case, it is 1.690
If I type 6 in B1, then it can work out 6-day simple moving average.
In this case, it is 1.6450

Starting point is the latest day which is 26 Mar (in this case) ....

Hope you can help ...
Thanks ....



"Joe User" wrote:

"Elton Law" wrote:
Say B3 to G3 are the prices.
[....]
Can you advise how to make it ...?
If I put a 3 in B1 ... Then it can calculate the 3-day moving
average in
C1.

I presume you mean a trailing simple moving average. If the prices
are in
row 3 starting with column B, put the following formula into C1 and
copy
across:

=IF(COLUMN(D3)-COLUMN($B$3)=$B$1,AVERAGE(OFFSET(D3,0,-$B$1,1,$B$1)),"")

If you want a leading SMA, then put the following into C1 and copy
across:

=IF(COUNT(OFFSET(C3,0,0,1,$B$1))=3,AVERAGE(OFFSET( C3,0,0,1,$B$1)),"")


----- original message -----

"Elton Law" wrote in message
...
Dear Expert,

Want to calculate Moving Average in this format.
But Sum is conditional

Say B2 to G2 are dates like this.
Say B3 to G3 are the prices.
A3 is Stock name
A2 is empty


Can you advise how to make it ...?
If I put a 3 in B1 ... Then it can calculate the 3-day moving
average in
C1.
If I put a 7 in D1 ... then it can calculate the 7-day moving
average in
E1

Moving average is dependent on the cell address to work out.
I have asked similar question before ... but the date is in
vertical
format.
This time .... If I present in horizontal format ... hope expert
can still
make it ....
Thanks

21-Mar 22-Mar 23-Mar 24-Mar 25-Mar 26-Mar
Stock Name 1.7 1.6 1.75 1.63 1.77 1.42


.


 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Conditional Sum - Moving Average Elton Law[_2_] Excel Worksheet Functions 0 March 28th 10 07:53 AM
Moving average billregal Excel Worksheet Functions 1 January 23rd 09 01:39 AM
moving average Hunter Excel Worksheet Functions 4 August 25th 06 02:34 PM
Moving average Hunterbo Charts and Charting in Excel 0 August 3rd 05 09:13 PM
Moving average Mike B Excel Worksheet Functions 8 March 21st 05 04:41 PM


All times are GMT +1. The time now is 12:34 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"