Login Page - Create Account

Support Board


Date/Time: Mon, 25 Nov 2024 11:21:12 +0000



Post From: Why Does Setting updatealways = 0 Still Trigger Function Calls on Every Chart Update Inter

[2024-03-16 03:52:03]
User372608 - Posts: 3
Following the guidelines from Referencing Other Time Frames and Symbols When Using the ACSIL in the section "Referencing Data from Other Time Frames By Direct Referencing of the Other Timeframe", I've implemented the example as shown:

SCSFExport scsf_ReferenceDataFromAnotherChart(SCStudyInterfaceRef sc)
{
SCInputRef ChartStudy = sc.Input[0];

if (sc.SetDefaults)
{
sc.GraphName = "Reference Data";
sc.StudyDescription = "This is an example of referencing data from another chart.";
sc.AutoLoop = 1;

ChartStudy.Name = "Study Reference";
ChartStudy.SetChartStudyValues(1, 1);

return;
}

// The following code is for getting the High array
// and corresponding index from another chart.

// Define a graph data object to get all of the base graph data from the specified chart
SCGraphData BaseGraphData;

// Get the base graph data from the specified chart
sc.GetChartBaseData(ChartStudy.GetChartNumber(), BaseGraphData);

// Define a reference to the High array
SCFloatArrayRef HighArray = BaseGraphData[SC_HIGH];

// Array is empty. Nothing to do.
if(HighArray.GetArraySize() == 0)
return;


// Get the index in the specified chart that is
// nearest to current index.
int RefChartIndex = sc.GetNearestMatchForDateTimeIndex(ChartStudy.GetChartNumber(), sc.Index);

float NearestRefChartHigh = HighArray[RefChartIndex];

// Get the index in the specified chart that contains
// the DateTime of the bar at the current index.
RefChartIndex = sc.GetContainingIndexForDateTimeIndex(ChartStudy.GetChartNumber(), sc.Index);

float ContainingRefChartHigh = HighArray[RefChartIndex];

// Get the index in the specified chart that exactly
// matches the DateTime of the current index.
RefChartIndex = sc.GetExactMatchForSCDateTime(ChartStudy.GetChartNumber(), sc.BaseDateTimeIn[sc.Index]);

if(RefChartIndex != -1)
{
float ExactMatchRefChartHigh = HighArray[RefChartIndex];
}

// The following code is for getting a study Subgraph array
// and corresponding index from another chart.
// For example, this could be a moving average study Subgraph.

// Define a graph data object to get all of the study data
SCGraphData StudyData;

// Get the study data from the specified chart
sc.GetStudyArraysFromChartUsingID(ChartStudy.GetChartNumber(), ChartStudy.GetStudyID(), StudyData);

// Define a reference to the first Subgraph array
SCFloatArrayRef SubgraphArray = StudyData[0];

// Array is empty. Nothing to do.
if(SubgraphArray.GetArraySize() == 0)
return;


// Get the index in the specified chart that is nearest
// to current index.
RefChartIndex = sc.GetNearestMatchForDateTimeIndex(ChartStudy.GetChartNumber(), sc.Index);

float NearestSubgraphValue = SubgraphArray[RefChartIndex];

// Get the index in the specified chart that contains
// the DateTime of the bar at the current index.
RefChartIndex = sc.GetContainingIndexForDateTimeIndex(ChartStudy.GetChartNumber(), sc.Index);

float ContainingSubgraphValue = SubgraphArray[RefChartIndex];

// Get the index in the specified chart that exactly
// matches the DateTime of the current index.
RefChartIndex = sc.GetExactMatchForSCDateTime(ChartStudy.GetChartNumber(), sc.BaseDateTimeIn[sc.Index]);

if(RefChartIndex != -1)//-1 means that there was not an exact match and therefore we do not have a valid index to work with
{
float ExactMatchSubgraphValue = SubgraphArray[RefChartIndex];
}
}


I have used GetChartBaseData as demonstrated, and found that even when setting updatealways = 0, it still calls at every chart update interval, even without new data arriving. When I remove the above code and set updatealways = 0, simply logging does not call at every chart update interval.

Could you help clarify why the function still gets called on every chart interval update despite setting updatealways = 0, and why it behaves differently when just logging without the previously mentioned code?