Login Page - Create Account

Support Board


Date/Time: Sat, 18 May 2024 07:58:48 +0000



Post From: Array Looping

[2016-09-28 20:40:44]
User103305 - Posts: 8
Then the example below will populate the arrays from right to left??? Does it mean that the sc.UpdateStartIndex hold the value -1?


This function demonstrates manual looping using a for loop.

/*----------------------------------------------------------------------------*/
SCSFExport scsf_ManualLoopExample(SCStudyInterfaceRef sc)
{

if (sc.SetDefaults)
{
// Set the configuration and defaults
sc.GraphName = "Manual Loop Example";

sc.StudyDescription = "This is an example of using manual looping.";
sc.AutoLoop = 0; // 0 is the default: there is no auto-looping

sc.Subgraph[0].Name = "High Low Difference";
sc.Subgraph[1].Name = "High - Low Average";

sc.Subgraph[2].Name = "Back Reference Example";
sc.Subgraph[3].Name = "Forward Reference Example";

return;
}

// Do data processing
for (int Index = sc.UpdateStartIndex; Index < sc.ArraySize; Index++)
{
// Calculate the difference between the high and the low
sc.Subgraph[0][Index] = sc.BaseData[SC_HIGH][Index] - sc.BaseData[SC_LOW][Index];

// SimpleMovAvg will fill in the data element in sc.Subgraph[1] at index Index.
sc.SimpleMovAvg(sc.Subgraph[0], sc.Subgraph[1], Index, 10);

// Copy the previous last price (Index-1) to subgraph array number 3
sc.Subgraph[2][Index] = sc.BaseData[SC_LAST][Index - 1];

// Copy the next last price (Index+1) to subgraph array number 4
sc.Subgraph[3][Index] = sc.BaseData[SC_LAST][Index + 1];
}
}

Date Time Of Last Edit: 2016-09-28 23:55:01