Login Page - Create Account

Support Board


Date/Time: Mon, 16 Sep 2024 19:36:59 +0000



[User Discussion] - Persistent variables not working?

View Count: 1736

[2014-04-09 20:35:54]
joshtrader - Posts: 485
I've created two charts (SC 1116 non-.net version). One is #11, and a custom study sets a persistent integer variable. The other is #12 and another test custom study references this variable. As you can see from this image, there is indeed a reference established:

http://screencast.com/t/Z1TRw1UT6bm

Yet in the debut output, notice the highlighted lines in the message log:

http://screencast.com/t/Pv4wGomMv

i1 is still set to zero as you can see in the above output, even though the source chart is setting it to 25.

Here is the very simple code, it is very simple, yet it does not seem to be working. Both charts have only the single custom test study. I have done this on a blank workbook with only the two charts open as well, with the same result. What is going on here??:


SCSFExport scsf_SetPVars(SCStudyInterfaceRef sc)
{
  if (sc.SetDefaults)
  {
    sc.GraphName="Set PVars Test";
    sc.StudyDescription="";
    
    sc.AutoLoop = 0;
    sc.GraphRegion = 0;
    sc.FreeDLL = 1;
    
    return;
  }
  
  if (sc.Index == 0)
  {
    sc.PersistVars->Integers[0] = 25;
    
    SCString buffer;
    buffer.Format("Just set Integers0 to: %d", sc.PersistVars->Integers[0]);
    sc.AddMessageToLog(buffer,0);
  }
}



SCSFExport scsf_GetPVars(SCStudyInterfaceRef sc)
{
  if (sc.SetDefaults)
  {
    sc.GraphName="Get PVars Test";
    sc.StudyDescription="";
    
    sc.AutoLoop = 0;
    sc.GraphRegion = 0;
    sc.FreeDLL = 1;
    
    return;
  }
  
  const s_sc::s_PersistentVariables * p_PersistVars =
    sc.GetStudyPersistentVariablesFromChartUsingID(11, 1); // chart #11, study #1

  if (p_PersistVars)
  {
    SCString buffer;
    buffer.Format("Integer i1 is: %d", p_PersistVars->i1);
    sc.AddMessageToLog(buffer,0);
  }
}

Date Time Of Last Edit: 2014-04-09 20:41:59
[2014-04-10 02:16:03]
Sierra Chart Engineering - Posts: 104368
sc.GetStudyPersistentVariablesFromChartUsingID(11, 1); // chart #11, study #1

The second number needs to be the study ID. Might not be 1.
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
[2014-04-10 02:29:02]
joshtrader - Posts: 485
As I said above, I have added this to charts as the only study, and confirmed that the study ID is 1. As you can see from the output in the message log, p_PersistVars is not null, so the call to get the persistent vars is working. In addition, as the first screenshot shows, there is a reference being created between the two charts via the function call, so clearly the study ID is correct.
Date Time Of Last Edit: 2014-04-10 02:30:15
[2014-04-10 02:39:56]
Sierra Chart Engineering - Posts: 104368
Integers [0] and i1 are different.
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
[2014-04-10 03:03:06]
joshtrader - Posts: 485
Arg, this is it--thanks guys.

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

Login

Login Page - Create Account