Support Board
Date/Time: Sun, 22 Dec 2024 07:57:52 +0000
How to reference Persistent Variables from a different chart.
View Count: 2772
[2015-04-18 06:52:41] |
CustomIndicators - Posts: 126 |
I'm building an ACSIL bot that will need to cross reference data from the studies of multiple charts at once. I have the key values in persistent variables at the moment, and I'm having trouble finding the right SC code to reference the PersVars from another chart. Is it possible to access this data from another study? |
[2015-04-18 22:19:09] |
Sierra Chart Engineering - Posts: 104368 |
There are functions like these: sc.GetStudyPersistentDoubleFromChart We will document them. 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 Date Time Of Last Edit: 2015-04-18 22:20:38
|
[2015-04-19 21:05:21] |
CustomIndicators - Posts: 126 |
Please let me know when you are finished documenting this. Also, are there many other sc functions that aren't documented yet? |
[2015-04-19 22:41:44] |
Sierra Chart Engineering - Posts: 104368 |
Here is the documentation: https://www.sierrachart.com/index.php?page=doc/doc_ACSIL_Members_Functions.html#scGetStudyPersistentIntFromChart There are a few functions which are undocumented. Have a look at the SierraChart.h file. If you have a question about something which is not documented, let us know. 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 |
[2015-04-20 05:29:34] |
CustomIndicators - Posts: 126 |
Thank you for documenting this code. I feel that it will help me greatly. Now, I have a couple questions about that code, as it doesn't seem completely clear to me. Lets say I have a study on chart 1, where I need to retrieve the double persistent variable called peakOne, on a study called MyIndicator. Do I have to use peakOne as the variable name on the study that is asking about the other chart? For instance: float & peakOne = sc.GetStudyPersistentFloatFromChart(1, MyIndicator, key); Also, what exactly does the Key value refer to? I'm trying to retrieve a value, not set one. |
[2015-04-20 23:02:57] |
CustomIndicators - Posts: 126 |
Hmmm, well, at least answer me this please. Is "1", the Key for this?: float& peakOne = sc.PersistVars->f1; |
[2015-04-21 03:49:23] |
Sierra Chart Engineering - Posts: 104368 |
Here is an example which should make this more clear: SCSFExport scsf_GetStudyPersistentVariableFromChartExample(SCStudyInterfaceRef sc)
{ SCInputRef ChartStudyReference = sc.Input[0]; if (sc.SetDefaults) { // Set the configuration and defaults sc.GraphName = "Get Study Persistent Variable from Chart Example"; sc.AutoLoop = 1; sc.FreeDLL = 0; ChartStudyReference.Name = "Chart Study Reference"; ChartStudyReference.SetChartStudyValues(1, 0); return; } //Set persistent float variable with a value of 100 using integer key 1. float & PersistentFloat = sc.GetPersistentFloat(1); PersistentFloat = 100; // Get a reference to a persistent variable with key value 100 in the chart // and study specified by the "Chart Study Reference" input. Assuming the // "Chart Study Reference" input is referencing this particular chart and // study instance, then FloatFromChartStudy will equal 100. float & FloatFromChartStudy = sc.GetStudyPersistentFloatFromChart(ChartStudyReference.GetChartNumber(), ChartStudyReference.GetStudyID(), 1); } The persistent variable is being set and get within the same function but this works across charts and studies as well. Just make sure you use the same Key value. 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 Date Time Of Last Edit: 2015-04-21 03:52:42
|
[2015-04-21 05:46:08] |
CustomIndicators - Posts: 126 |
Now, just one last question should top it off. Your example has greatly helped in my understanding. You set the following in your example code. float & PersistentFloat = sc.GetPersistentFloat(1);
In my code right now, I have this:float& peakOne = sc.PersistVars->f1;
Does this mean that I should change my code to this?:float& peakOne = sc.GetPersistentFloat(1);
Or should I do something more like this?:float& peakOne = sc.PersistVars->f1;
And then from there, I can reference it from other charts?
peakOne = sc.GetPersistentFloat(1); |
[2015-04-21 07:16:32] |
Sierra Chart Engineering - Posts: 104368 |
Does this mean that I should change my code to this?: 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 |
[2015-04-21 07:45:37] |
CustomIndicators - Posts: 126 |
Awesome! Thank you for taking the time to answer my questions. :)
|
To post a message in this thread, you need to log in with your Sierra Chart account: