Login Page - Create Account

Support Board


Date/Time: Wed, 27 Nov 2024 02:26:10 +0000



[Programming Help] - How to add Reset At Both Session Times to the Cumulative Sum of Study study?

View Count: 717

[2023-06-16 03:28:29]
j4ytr4der_ - Posts: 938
Based on the issue in this thread: Cumulative Sum of Study resets at evening session, not morning session?

I'm trying to add a feature from Cumulative Delta Bars - Volume. It has an option to reset at both session start times, as opposed to only at the evening session start.

I thought maybe this would be pretty simple, just rip some code out of the Delta Bars study and toss it into the Cumulative Sum study. But unfortunately it hasn't worked at all, and I'm not a programmer so have no idea how to troubleshoot this thing.

Could anyone who has more ACSIL skills than I, help out with this? I literally just want that one additional option, Reset At Both Session Start Times. Huge appreciation to anyone who knows how to cobble that together and can lend a hand!
[2023-06-16 08:47:22]
User431178 - Posts: 543
Example attached.
Code ripped from delta bars and tossed into cumulative sum as requested.
attachmentCumulativeSumOfStudy.cpp - Attached On 2023-06-16 08:45:11 UTC - Size: 2.99 KB - 272 views
[2023-06-16 12:57:45]
j4ytr4der_ - Posts: 938
Oh wow, fan-freaking-tastic! Maybe now I can learn where I was going wrong. Much appreciated!
[2023-06-16 13:15:40]
j4ytr4der_ - Posts: 938
Works like a charm, AND I see what I was missing from my own attempt. Was so close... lol

Thank you again, you've relieved an annoying headache!
[2023-06-23 13:18:43]
j4ytr4der_ - Posts: 938
I stand corrected, I just realized that it's not summing the result of the study (a Spreadsheet Formula) overnight, pre-open. I believe it's been working correctly in RTH, but looking at it right now 15 minutes to the open, it is most definitely not accumulating anything. It's giving me the correct calculation of only the current bar, of the study it's supposed to be accumulating. Any idea why that would be happening?

Also to be fair this is nothing to do with the change you made, as the stock study does this as well. Not resetting at start of trading day (that setting appears to have no effect in this case). It DOES accumulate properly if I point it to something else like a value from the Numbers Bars Calculated Values study, but it doesn't accumulate a spreadsheet study for some reason. Can just set a spreadsheet study to something silly like H and try to accumulate that, it doesn't work.

Can anyone else verify this? Is this a bug in the Cumulative Sum of Study study itself?
[2023-06-23 13:29:31]
User431178 - Posts: 543
Change this line

sc.CalculationPrecedence = LOW_PREC_LEVEL;

to

sc.CalculationPrecedence = VERY_LOW_PREC_LEVEL;

and make sure the Spreadsheet Formula study is below the cumulative sum study in the studies window.
Spreadsheet Formula is very low precedence.
[2023-06-23 14:03:17]
j4ytr4der_ - Posts: 938
OK this is totally bizarre, but I just discovered that actually all I have to do is recalculate the chart manually, and the sum suddenly kicks in. Regardless of the ordering of the studies. I have not made any other changes at this point. Bizarre.
[2023-06-23 14:13:44]
Sawtooth - Posts: 4120
all I have to do is recalculate the chart manually
You can use the Chart Recalculation - Periodic study to automate it.
[2023-06-23 14:15:33]
j4ytr4der_ - Posts: 938
Yeah but I don't want it constantly recalculating. It should perform a recalc automatically when the study settings are applied anyway. Doesn't seem right. I just have to remain aware of this and make sure I recalculate after changing any study settings so that my calc value is correct. Hopefully I shouldn't be changing study settings a lot anyway.
[2023-06-23 14:29:22]
j4ytr4der_ - Posts: 938
Actually I think I'll put a recalc study on as a failsafe but maybe only recalcing every minute. That way worst case even if I forget to recalculate manually it'll only be 60 seconds or less that it's got the wrong value, and overhead still shouldn't be too terrible.

Still feels like a bug in the cum. sum study... maybe someone clever-er than I can fix it.
[2023-06-23 14:49:07]
User431178 - Posts: 543
Still feels like a bug in the cum. sum study... maybe someone clever-er than I can fix it.

Not a bug, just happens that when you first calculate, the referenced study is calculated after the cumlative sum study, hence there is not data to reference.
Next time you recalculate, as long as the referenced study does not get cleared, then the values are available for the cumulative study, regardless of calculation precedence.

The solution is already listed above, there is no other way, other than the manual/auto re-calc (which is a fudge/patch, not really a solution).
[2023-06-23 15:03:23]
j4ytr4der_ - Posts: 938
Gotcha. So the real solution to this requires changing the code and recompiling the study. Simply changing the order of the studies made no difference at all.

I have a hard time not seeing that as a bug but... as long as I know a solution, I can work with it. Thanks.
[2023-06-23 15:19:49]
User431178 - Posts: 543
Yes, exactly, changing the order as it is now makes no difference, that would only be effective if they were already the same precedence level.

Chart Studies: Study Calculation Precedence And Related Issues
[2023-06-23 15:29:09]
j4ytr4der_ - Posts: 938
Yep changing the precedence level alone solved it. Thanks for the tip.
[2023-10-06 04:13:33]
j4ytr4der_ - Posts: 938
So I'm revisiting this again, sortof. Now I'm working on a different study entirely, but I would also like to have the option for resetting at both session starts. However, this one uses autoloop, and I can't find a single example in the included source code, where a reset is performed with an autolooping study.

Can anyone guide me on how to accomplish this?
[2023-10-06 04:24:58]
j4ytr4der_ - Posts: 938
Actually I think I should explain more. I'm plotting extension lines using sc.AddLineUntilFutureIntersection, and I would like to have the option to have them stop at the end of the session. I'm not sure this is as straight forward as a "reset at session start" option.

To post a message in this thread, you need to log in with your Sierra Chart account:

Login

Login Page - Create Account