Support Board
Date/Time: Mon, 25 Nov 2024 18:35:15 +0000
[Programming Help] - sc.persistvars ERROR
View Count: 1145
[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 |
[2019-05-31 01:26:18] |
Sierra Chart Engineering - Posts: 104368 |
You need to use the new persistent variable functions instead: sc.GetPersistentInt() 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 |
[2024-02-06 21:29:10] |
jivetrader - Posts: 410 |
Could someone please provide the 3 new lines of code for this study, replacing the Persist function with the newer, proper function? I have no idea how to do this. Thank you int &dateToday = sc.PersistVars->i1; ... float OSHighNum = sc.PersistVars->f1; float OSLowNum = sc.PersistVars->f2; |
[2024-02-10 21:24:08] |
ForgivingComputers.com - Posts: 960 |
int& dateToday = sc.GetPersistentInt(1); ... float& OSHighNum = sc.GetPersistentFloat(1); float& OSLowNum = sc.GetPersistentFloat(2); |
[2024-02-16 05:55:22] |
jivetrader - Posts: 410 |
I replaced the 3 outdated lines with the bradh's code, and compiled it with an old version of Sierra. For me this study only highlights the first bar's high and low regardless of timeframe, not the opening swing.
|
To post a message in this thread, you need to log in with your Sierra Chart account: