+ Reply to Thread
Results 1 to 3 of 3

Simple Moving Averages & VB Coding

  1. #1
    Registered User
    Join Date
    09-05-2011
    Location
    St. John's, Canada
    MS-Off Ver
    Excel 2010
    Posts
    70

    Simple Moving Averages & VB Coding

    Hey Everyone,

    I'm just starting a new project and my first task is to create two Simple Moving Averages (SMA) and compare them. For example I have a data set that changes each day, similar to a stock or currency. I want to calculate a Long SMA and a Short SMA. A Long SMA would be the average of say the last 20 data points, and a Short SMA the average of the Last 10 Data Points at a given date in time. As time moves ahead the average would continue to move ahead with it.

    The challenge is however, I am required to be able to change how many data points the long and short SMAs take into consideration. One iteration of the code I may be required to use 20 & 10 data points, and upon the next iteration I may wish to use 21 & 9 data points. the Pseudo Code would look something like this:

    On January 1 2000

    LongSMA = B3 = X
    ShortSMA = C3 = Y

    Take the average as of January 1 2000 going back X days and record it in cell D4
    Take the average as of January 1 2000 going back Y days and record it in cell E4

    Move ahead one day & record averages in Cell B4 & C4, respectively

    Cont....

    I have attached a sample Work Book with Two Worksheets to help illustrate my question.

    Any thoughts ?

    Sorry for the long winded question.
    Attached Files Attached Files
    Last edited by ashleys.nl; 01-04-2012 at 08:35 PM.

  2. #2
    Forum Expert
    Join Date
    11-29-2010
    Location
    Ukraine
    MS-Off Ver
    Excel 2019
    Posts
    4,168

    Re: Simple Moving Averages & VB Coding

    hi ashleys.nl, please check attachment, I hope this helps
    Attached Files Attached Files

  3. #3
    Registered User
    Join Date
    09-05-2011
    Location
    St. John's, Canada
    MS-Off Ver
    Excel 2010
    Posts
    70

    Re: Simple Moving Averages & VB Coding

    Awesome! I think I can work with that, thank you soo much for your help

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1