I wanted to post some past
ADL logic suggestions for capturing data sets over user defined time intervals.
This kind of logic is very useful when creating Technical Indicator type
calculations and behaviors:
Basically, the trick
is to use a Value Bucket (VB) Block with internal setting Store Type set to
'Last' along with a 'Bucket Hole Formula' input for the VB Block that is a modulo, or in this example you are setting this as the “result output” from the DivRem
calculation in the Math Block. Modulo is a mathematical function that outputs the
remainder when you divide total bars by window. For example, let's say the
look back window is 5. If 4 bars have completed: 4 / 5 = 0 r 4 so the output of
this calc is 4. Now let's say 23 bars have completed: 23 / 5 = 4 r 3 so the
output of this calc is 3.
If you use this as your Bucket Hole Formula input in the VB Block, then you will be replacing old values (b/c of the 'Last' setting) such that the last x min values are always stored, though not in the correct order. However, this doesn't matter since the min of a set of values is not determined by their order! As an example, if look back window is 5 and the 6th bar has just completed, 6 / 5 = 1 r 1 such that the 6th bar will be stored in the 1st slot, replacing the 1st bar value. Now, the VB block has stored the 6th, 2nd, 3rd, 4th, and 5th values in that order. This will continue on infinitum.
Finally, downstream from properly populating the VB Block, you can run a Loop Block that checks all values in the VB Block by using the Loop Block's 'CurrIndex' as the Hole input for the VB Block. Use the discrete message from the Loop Block to trigger the capturing of the VB Block value in a Discrete Min Block. After the Loop Block has completed, you can use the Exit output from it to trigger a Value Extractor Block to capture the Discrete Min's output which will at this point be your desired value.
Please keep in mind that this stores the last x values in the VB Block in the wrong order so certain computations can be effected by this (for example an exponential moving average). Min and max are OK here.
In the below screen shot example of the logic, you will see it is set
for a look back period of 4. You can see how the values are logged and stored.