Login Page - Create Account

Support Board


Date/Time: Tue, 26 Nov 2024 22:14:40 +0000



[Programming Help] - What happens when I click OK/Apply in Studies window?

View Count: 693

[2022-06-27 22:02:00]
User145575 - Posts: 20
Hello,
I am working on an ACSIL study that, for various reasons I need to occasionally recalculate. Usually due to market speed, for example in a flurry of candles, some calculations are sometimes missed. I have found that if I open the Studies modal (press F6) and click Apply or OK, my study is reloaded perfectly, and any missed candles are recalculated nicely. But if I click Chart->Recalculate, or even Chart->Reload and Recalculate, it doesn't seem to reload my study. Likewise, if I programmatically flag a recalculation (by setting sc.FlagFullRecalculate to 1), it does not go back and recalculate all my bars. So, there is something special happening when clicking ok/apply in that Studies window, that is different from a "recalculate." Can you tell me what it is, and how I might programmatically do it?

Thank you!
[2022-06-28 14:50:39]
User839162 - Posts: 87
Great question. Hopefully Support can answer this.
[2022-06-28 15:23:11]
User431178 - Posts: 543
Did you already read the information here - Working with ACSIL Arrays and Understanding Looping

The 'something special' most likely relates to study arrays being cleared (which happens when you go into studies window and apply).

Also, how is the study 'missing calculations'? Can you elaborate?

Likewise, if I programmatically flag a recalculation (by setting sc.FlagFullRecalculate to 1), it does not go back and recalculate all my bars.
This must be a logic error in your study, as on the rare occasions I am using it, it does exactly as described - loops through the entire chart from index 0.
[2022-06-28 16:06:00]
User145575 - Posts: 20
The 'something special' most likely relates to study arrays being cleared (which happens when you go into studies window and apply).

Oh that could be it. My study does have some specialized initialization logic, and it's quite possible that I just haven't written that right, to deal with a recalc.

I've definitely read (and re-read!) the arrays and looping article. But thank you for the new perspective--I have a couple of ideas to hone in on now.
[2022-07-01 12:48:53]
Sierra Chart Engineering - Posts: 104368
But if I click Chart->Recalculate, or even Chart->Reload and Recalculate, it doesn't seem to reload my study.
A recalculation of the study definitively occurs. However, if you are using manual looping you may not be doing this properly.

Likewise, if I programmatically flag a recalculation (by setting sc.FlagFullRecalculate to 1), it does not go back and recalculate all my bars.
This would be a problem in your study then. Not with Sierra Chart.

We have added this section to explain when study arrays are cleared:
Working with ACSIL Arrays and Understanding Looping: When Arrays are Cleared
Sierra Chart Support - Engineering Level

Your definitive source for support. Other responses are from users. Try to keep your questions brief and to the point. Be aware of support policy:
https://www.sierrachart.com/index.php?l=PostingInformation.php#GeneralInformation

For the most reliable, advanced, and zero cost futures order routing, *change* to the Teton service:
Sierra Chart Teton Futures Order Routing
[2023-10-14 05:35:31]
User907967 - Posts: 54
Hi all,

I struggled with this for months (I still am). I have the same problem as the users above.

Let's assume I have developed a study. To avoid concern about manual/auto-looping, here is the relevant default section:

sc.AutoLoop = true;

I've also added one of the generic studies: Current Price Line.

My study uses subgraphs and the s_UseTool. Without going into too much detail, I use the subgraphs to carry values from one period to another. I avoid taking any action for the first few periods. When I decide to do so, I use the values in the subgraphs to draw various shapes. For the avoidance of doubt about the changes I am reporting, those refer to subgraphs (not to the s_UseTool). I understand how Arrays work from the ASCIL perspective, or at least I have sufficient understanding to develop a study from sc.Index = 0 with 5+ subgraphs, all handling various calculations.

This is what I struggle to understand:
Example 1 - If I compile my study, remove and add it, then press Ok/Apply from the Studies window (F6), it loads with no problems.
Example 2 - Pressing Insert achieves the same result.

Example 3 - However, if I press Chart> Recalculate, the Chart renders slightly different results, and I struggle to understand why.
Example 4 - Equally, if I load the settings for the Current Price Line and then press Apply, I get the same (less desirable) results.

I get that a recalculation is involved in the second two examples, but it is not the same recalculation as if I acted in the first two examples.

I enforced the following code just after the end of the Defaults section of the study to see how it behaves:
Example 5
c.FlagFullRecalculate = true;

In this fifth example, I can see for a split second the study loads as I expect it to load, then immediately after, it starts to refresh consecutively, showing the outputs I am not expecting to see. This confirms that the 'refreshing' triggered in examples 3, 4 and 5 is slightly different than that in examples 1 and 2.

I wrote this post as explicitly and detailed as possible to show you my thought process. I kindly ask the Sierra Chart support/engineering team to help us understand what we are missing.

Temporary solution
Because I was unable to understand what was happening in this "full" recalculation (examples 3-5) that does not occur in a standard load (examples 1-2), as an interim solution, I decided to force my study to
exit
if it feels a full recalculation is underway. I don't think that's an excellent long-term solution. I want to learn to work with SierraCharts, but I can only patch my study this way until it's clear what's different between these two scenarios. On a few occasions, I also felt that it did not work (so if I had hit Apply on other studies, my study would still change in a way I can't tell what has gone wrong).

Here's the patch, written just under the Definitions:
if (sc.FlagFullRecalculate == true) { exit; }

Thank you.
Date Time Of Last Edit: 2023-10-14 05:45:03

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

Login

Login Page - Create Account