This question may not seem like it, but I have spent many hours trying to figure this function out. Just when I think I have a firm understanding, and I'm retrieving exactly what I'd expect, the next moment I write a new script and the data is close, but too far off for me to feel comfortable using it.
Can someone please explain to me, without using code logic, exactly what the attached code is doing? Please do not refer me to any of the tutorials on here or the learning center at https://tlc.thinkorswim.com/center/reference/thinkScript/Functions/Others/CompoundValue. I have spent HOURS trying to fully understand this. Really all I need is for someone to correct what is wrong with my interpretation.
My interpretation:
Sets 'postmarket_volume' equal to what 'postmarket_volume' previously was PLUS the current minute's total volume. Because 'postmarket_volume' was never set to anything, due to 'after_hours_start' being 1600, the result should be the exact amount of volume from 1600 to the current time in the same day.
What I assume is happening, using 1m aggregation:
An iteration through the day, starting at 0400, looping through each minute. As soon as 1600 is hit (>=0 seconds from 1600 using the if statement), 'postmarket_volume' is set to 'volume+postmarket_volume[1]', with 'postmarket_volume' previously being 0. Since the else statement is never true, the else statement should never be used.
Thank you in advance.
Can someone please explain to me, without using code logic, exactly what the attached code is doing? Please do not refer me to any of the tutorials on here or the learning center at https://tlc.thinkorswim.com/center/reference/thinkScript/Functions/Others/CompoundValue. I have spent HOURS trying to fully understand this. Really all I need is for someone to correct what is wrong with my interpretation.
My interpretation:
Sets 'postmarket_volume' equal to what 'postmarket_volume' previously was PLUS the current minute's total volume. Because 'postmarket_volume' was never set to anything, due to 'after_hours_start' being 1600, the result should be the exact amount of volume from 1600 to the current time in the same day.
What I assume is happening, using 1m aggregation:
An iteration through the day, starting at 0400, looping through each minute. As soon as 1600 is hit (>=0 seconds from 1600 using the if statement), 'postmarket_volume' is set to 'volume+postmarket_volume[1]', with 'postmarket_volume' previously being 0. Since the else statement is never true, the else statement should never be used.
Code:
input after_hours_start = 1600;
rec postmarket_volume = CompoundValue(1, if secondsfromtime(after_hours_start) >=0 then volume+postmarket_volume[1] else postmarket_volume[1],0);
Thank you in advance.