Login Page - Create Account

Support Board


Date/Time: Sun, 05 May 2024 18:46:11 +0000



Post From: Referencing to Persistent Variable by name NOT working *URGENT*

[2016-02-22 10:58:29]
User972044 - Posts: 154
And furthermore, your documentation about another method of using persistent variables via the sc.PersistVars->... function in http://www.sierrachart.com/index.php?page=doc/doc_ACSIL_Members_Variables_And_Arrays.html

even states that "Initial Value: 0 (for all the persistent variables in the structure)" and "All persistent variables are set to zero values when an instance of the study is added to the chart or when a chartbook is loaded and an instance of the study is contained on a chart in the chartbook." So if (sc.Index == 0) is not even needed. And that's even more INACCURATE.

I used int& MyCounter = sc.PersistVars->Integers[0]; EXACTLY as how it is stated in the documentation but when I run the program, this is the value that I got from the first time when the study was run:

Chart: GBPUSD [M] 1 Min #1 | Study: Custom DLL Study | MyCounter Value is 175113 | 2016-02-22 05:47:59

When my code is MyCounter += 1; within the if (sc.GetBarHasClosedStatus() == BHCS_BAR_HAS_CLOSED){} block. So according to my code, the value of MyCounter should be 1 the first time when the study is run and NOT 175113.

And even though the documentation states that "Initial Value: 0 (for all the persistent variables in the structure)" and "All persistent variables are set to zero values when an instance of the study is added to the chart or when a chartbook is loaded and an instance of the study is contained on a chart in the chartbook.", the documentation still provided the resetting persistent variable example at (if sc.Index == 0){ sc.PersistVars -> Integers[0] = 0; } I used that example and I received the same random value as previously when I used the SetPersistentInt() method or variable_name = 0; statement as follows, 87XXX:

Chart: GBPUSD [M] 1 Min #1 | Study: Custom DLL Study | MyCounter Value is 87573 | 2016-02-22 06:03:58

So WHY would there be two different explanations regarding how the initial value of persistent variables to be set and WHY is neither of the pointer reference working?

Please advise and help.

Thank you.
Date Time Of Last Edit: 2016-02-22 11:08:47