Login Page - Create Account

Support Board


Date/Time: Mon, 25 Nov 2024 18:56:09 +0000



Post From: sc.persistvars ERROR

[2019-05-30 20:40:10]
User710679 - Posts: 43
hi, i am trying to compile the following code:

/*****************************************************************************

This is a C++ source code file. This file contains example Advanced Custom

Study functions. It also contains functions for some built-in studies

in Sierra Chart.

*****************************************************************************/

#include "sierrachart.h"

/****************************************************************************/

SCDLLName("OS Marker")
SCSFExport scsf_OSMarker(SCStudyInterfaceRef sc)

{

SCSubgraphRef OSHigh = sc.Subgraph[0];
SCSubgraphRef OSLow = sc.Subgraph[1];
SCSubgraphRef OSRange = sc.Subgraph[2];


// Set configuration variables

if (sc.SetDefaults)
{

sc.GraphName = "OS Marker";
sc.StudyDescription = "Marks the Opening Swing High and Low";

sc.Input[1].Name = "Day Session Start";
sc.Input[1].SetTime(HMS_TIME(15,30,0));

sc.Input[2].Name = "Day Session End";
sc.Input[2].SetTime(HMS_TIME(22,00,00));


// Set the region to draw the graph in. Region zero is the main
// price graph region.
sc.GraphRegion = 0;

// Set the name of the first subgraph
OSHigh.Name = "Opening Swing High";
OSLow.Name = "Opening Swing Low";

sc.AutoLoop = 1;

// During development set this flag to 1, so the DLL can be modified. When development is completed, set it to 0 to improve performance.
sc.FreeDLL = 0;

// Must return before doing any data processing if sc.SetDefaults is set
return;
}

// Bar index of beginning of trading day for bar at current index. This depends upon auto looping being true.


int &dateToday = sc.PersistVars->i1;

SCDateTime BarDateTime = sc.BaseDateTimeIn[sc.Index];
dateToday = BarDateTime.GetDate();
SCDateTime StartTimeToday;
SCDateTime EndTimeToday;

float OSHighNum = sc.PersistVars->f1;
float OSLowNum = sc.PersistVars->f2;

StartTimeToday.SetDateTime(dateToday, sc.Input[1].GetTime());
EndTimeToday.SetDateTime(dateToday, sc.Input[2].GetTime());

int StartOfDayIndex = sc.GetContainingIndexForSCDateTime(sc.ChartNumber, StartTimeToday);
int EndOfDayIndex = sc.GetContainingIndexForSCDateTime(sc.ChartNumber, EndTimeToday);

if(sc.Index == StartOfDayIndex) {

OSHighNum = sc.BaseData[SC_HIGH][StartOfDayIndex];
OSLowNum = sc.BaseData[SC_LOW][StartOfDayIndex];
OSHigh[sc.Index] = OSHighNum;
OSLow[sc.Index] = OSLowNum;

OSHigh.ExtendedArrayElementsToGraph = 10;
OSLow.ExtendedArrayElementsToGraph = 10;

}

else {

OSHigh[sc.Index] = OSHigh[sc.Index - 1];
OSLow[sc.Index] = OSLow[sc.Index - 1];
}

}

and i am getting the following errors:


OR.cpp: In function 'void scsf_OSMarker(SCStudyInterfaceRef)':
OR.cpp:60:23: error: 'struct s_sc' has no member named 'PersistVars'
int &dateToday = sc.PersistVars->i1;
^
OR.cpp:67:24: error: 'struct s_sc' has no member named 'PersistVars'
float OSHighNum = sc.PersistVars->f1;
^
OR.cpp:68:23: error: 'struct s_sc' has no member named 'PersistVars'
float OSLowNum = sc.PersistVars->f2;
^

i would appreciate any help!

thanks a lot

David