So i have a value bucket generating a new value every second and I want to sum just the last 60 values generated or the last 60 second of values for example. So every second it drops the 61st value and adds the latest value. Is there a simple way to do this? Seems like it would be easy but I'm stuck on this problem. Thanks in advance

Comment

**Answer** by sashidareddy
·
Jun 07 at 06:16 PM

What if you use the Moving Average Block - which does exactly what you are looking for but gives you the average instead of sum. All you have to do is multiply the output from the moving average by the "#bars" parameter of the moving average block to get the sum of last n-values. See https://library.tradingtechnologies.com/adl/db-moving-average-block.html

**Answer** by brian
·
Jun 07 at 11:52 PM

Hmmm yeah the math on that would work I guess if I was using 1 sec bars... but the analytics bar doesn't support that. I ended up doing a time based configuration where I sum up each second and then subtracting past seconds. I was after bid/ask volume. Here's what I came up with.

2020-06-07-1949.png
(336.3 kB)

**Answer** by Digital Jester
·
Sep 09 at 10:45 PM

Generator Block connected to sequencer blocks connected to value extractor blocks.

The first sequenced block connects to an extractor that holds your oldest price.

The second sequenced block connects to an extractor that holds your second oldest price.

...

The last (X) sequenced block connects to an extractor (X) that holds your newest price.

When the first sequenced message triggers the first extractor block it copies the second extractor block.

When the second sequenced message triggers the second extractor block it copies the third extractor block.

...

When the second to last (X-1) sequenced message triggers the second to last (X-1) extractor block it copies the last extractor block (X).

When the last (X) sequenced message triggers the last extractor (X) block it copies the current market price.

Hence you extractor blocks now have the last X seconds worth of prices. Would be a little cumbersome for holding X=60 seconds but you could make it easier by have nested groups.

Ask questions and share ideas about the TT^{®} and X_TRADER^{®} platforms.

First time here? See our Getting Started Guide and FAQs.

Follow
### Follow this Question

© 2017 Trading Technologies International, Inc. All rights reserved.

Powered by AnswerHub