+ Reply to Thread
Results 1 to 3 of 3

Dealing with timestamps and averages over 5 minutes

  1. #1
    Registered User
    Join Date
    04-28-2013
    Location
    Stockholm
    MS-Off Ver
    Excel 2007
    Posts
    93

    Dealing with timestamps and averages over 5 minutes

    This is the data I'm working with. Every NBBO midpoint corresponds to a tradetime. What I need is the average midpoint over the next 5 minutes of a given trade. For example, with the first trade (at 09:00:13), I need the average midpoint up till 09:05:13, and then like this for every trade. Any ideas?
    Attached Files Attached Files

  2. #2
    Valued Forum Contributor Lemice's Avatar
    Join Date
    04-13-2013
    Location
    Somewhere.
    MS-Off Ver
    Excel 2016
    Posts
    696

    Re: Dealing with timestamps and averages over 5 minutes

    Hello,

    These might be the formula you want, yes, there are two with two way of calculating. Paste either of them on C2 and drag them down.
    Please Login or Register  to view this content.
    This first formula is the general one-for-all-purpose formula, which will find the average of all midpoint with the tradetime in the range of the tradetime in A2 and A2 plus 5 minutes.

    The second formula
    Please Login or Register  to view this content.
    This will run faster and does not take as much resources as the first, but only under one condition: you have sorted the tradetime column.

    Note that if you paste them on C2 and D2, then drag them down, they will slightly different from each other by an amount of smaller than 0.01 at the best, and smaller than 0.0001 on most other cases, because Excel does not calculate the decimal number with precision, so even a simple calculation like
    1*(0.5-0.4-0.1)
    will not return 0, so expect a very small amount of difference in results from them.

    Here is your sample with both formula, the first on column C, the second on column D, and column E showing the tiny difference.
    Attached Files Attached Files
    (copy pasta from Ford)
    1. Use code tags for VBA. [code] Your Code [/code] (or use the # button)
    2. If your question is resolved, mark it SOLVED using the thread tools

    Regards,
    Lem

  3. #3
    Registered User
    Join Date
    04-28-2013
    Location
    Stockholm
    MS-Off Ver
    Excel 2007
    Posts
    93

    Re: Dealing with timestamps and averages over 5 minutes

    Thank you very much, you're a legend!

+ 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