+ Reply to Thread
Results 1 to 7 of 7

How to record the amount a cell consecutively rises or falls.

  1. #1
    Registered User
    Join Date
    11-13-2009
    Location
    France
    MS-Off Ver
    Excel 2007
    Posts
    32

    How to record the amount a cell consecutively rises or falls.

    I cannot work this out!

    I have live Dynamic Data of share prices feeding into Excel.

    Imagine cell A1 contains one share price. The cell is constantly changing; rising and falling throughout the day.

    What I can't work out (and what I would greatly appreciate you help with) is how to determine the maximum size of a consecutive (uninterrupted) fall.

    So for example say the price changed as follows: 100, 101, 102, 103, 102, 101, 100, 99, 98, 97, 96, 97, 98, 99, 100.

    I would like to detect the uninterrupted drop between 103-96 and show in another cell, the size of the continuous fall which in this case is: 6.8% (103-96)/103).

    Then to keep that 6.8% figure displayed until it is replaced by a larger figure.

    Any ideas how this could be done??

    Many thanks.
    Last edited by holmwood; 11-20-2009 at 07:38 AM.

  2. #2
    Forum Expert
    Join Date
    08-27-2008
    Location
    England
    MS-Off Ver
    2010
    Posts
    2,561

    Re: How to record the amount a cell consecutively rises or falls.

    The only practical way is to append new information, rather than overwrite - the numbers have to be stored somewhere for the maths to be done on them

    How is the update achieved?

  3. #3
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: How to record the amount a cell consecutively rises or falls.

    Holmwood, I would suggest revisiting your earlier thread re: capturing the DDE update and tracking changes ... specifically the use of Static variables in the Calculate event.

  4. #4
    Valued Forum Contributor
    Join Date
    07-29-2009
    Location
    Belgium
    MS-Off Ver
    Excel 2003/Excel 2010
    Posts
    534

    Re: How to record the amount a cell consecutively rises or falls.

    Would this be a possibility? It's based on a macro by J. Beaucaire, maybe from the earlier thread Don refers to, i'm not sure.
    Change the (price) value in A1 to simulate a live feed.
    Attached Files Attached Files

  5. #5
    Registered User
    Join Date
    11-13-2009
    Location
    France
    MS-Off Ver
    Excel 2007
    Posts
    32

    Re: How to record the amount a cell consecutively rises or falls.

    Don Hi:

    I have never used VB basic, so when you said "..the use of Static variables in the Calculate event." means not a lot to me. The limit of my abilities was to copy your code and change the cell references. I am happy to learn if you point me in the direction of what I need to learn. The last time I programmed was basic Basic on my Commodore Pet in the early eighties!

    I was hoping for a formula, as I have 369 different DDE price feeds to monitor. You used 'prior' in your earlier code, (which incidentally is working well. Thank you.) this infers the previous value, I would need to capture many prior values, until the price stopped falling and then do the same for all 369 variables.

    I happily learn what I need to know, if you think the right code will solve the problem.

    Charlie:

    You said .."the numbers have to be stored somewhere for the maths to be done on them"

    This is the problem. With my knowledge, I can't figure out how to capture maybe up to 50+ prior events for each of 369 DDE price variables. The update is achieved via the data stream provider's desktop authentication program. Once started the prices start changing using cell formulas like =ADVFN|LSE_BARC!CHANGE_PC which would stream the %age price change on the day for Barclay's Bank.

    Wher:

    "Could I use the earlier code?"

    Don infers Yes, but with 369 varibles and mabe 50+ prior events to capture, I don't know where to begin to modify Don's previous code.
    Last edited by holmwood; 11-20-2009 at 11:32 AM.

  6. #6
    Forum Expert
    Join Date
    08-27-2008
    Location
    England
    MS-Off Ver
    2010
    Posts
    2,561

    Re: How to record the amount a cell consecutively rises or falls.

    Hmmm... the previous thread was an interesting read and I've been pondering; I have an idea, but I'm concerned about speed, you're saying you need 369 variables*50 previous values - this can be done (anything's possible) but depending on the update frequency, you may struggle to capture all the changes, and apply the appropriate calculations, in time... so, what's the update frequency?

  7. #7
    Registered User
    Join Date
    11-13-2009
    Location
    France
    MS-Off Ver
    Excel 2007
    Posts
    32

    Re: How to record the amount a cell consecutively rises or falls.

    Charlie, you say: ...what's the update frequency?

    It depends on the volume of shares traded per stock, per day. With some heavily traded stocks, their price may change several times a minute. Most would see a price change every few minutes, and some (with very low daily volumes traded) may see their price change only a few times a day.

    Does this answer your question?

+ 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