Support Board
Date/Time: Fri, 07 Nov 2025 03:47:42 +0000
Post From: Sequence of evaluation of interdependent studies during chart load?
| [2025-10-08 23:18:51] |
| rajeshh - Posts: 50 |
|
or a recalc is done, the study starts at Bar 0 and calculates the values for each study, then goes onto the next bar.
So I dont think the above is correct, as I suspected in my original post. I have written a sample study A, and B below. study A calculates a subgraph value when a bar closes, such that for bar X, it reassigns the subgraph value of every bar upto that bar to the index of X. IOW, when bar 1 closes, bar 0 subgraph value will be 1 and so on. So at the end of it, all bars in the chart will have the subgraph value of the last index in the chart. Study B just gets the value of subgraph from study A for a bar X, and prints it below the low of the bar X. If the calculation is happening as you say where A->B are calculated for every bar on chart loading, then one should see values 1, 2, 3, 4 etc, but B shows the value of the last index in the chart for all the bars. When one does a replay mode of the chart, then the values are correctly showing the current index of the bar. SCSFExport scsf_A(SCStudyInterfaceRef sc)
{ SCSubgraphRef Subgraph_a = sc.Subgraph[0]; if (sc.SetDefaults) { // Set the configuration and defaults sc.GraphName = "Test Sequence of Study Evaluation A"; sc.CalculationPrecedence = LOW_PREC_LEVEL; sc.AutoLoop = true; sc.GraphRegion = 0; sc.ValueFormat = VALUEFORMAT_INHERITED; // Set the name of the first subgraph Subgraph_a.Name = "Index of bar"; Subgraph_a.DrawStyle = DRAWSTYLE_SUBGRAPH_NAME_AND_VALUE_LABELS_ONLY; sc.ScaleRangeType = SCALE_SAMEASREGION; return; } int n = sc.Index; if (sc.GetBarHasClosedStatus() == BHCS_BAR_HAS_CLOSED) for (int tbl = n ; tbl >= 0; tbl--) { Subgraph_a[tbl] = n; } } SCSFExport scsf_B(SCStudyInterfaceRef sc) { SCSubgraphRef Subgraph_a = sc.Subgraph[0]; SCInputRef Input_AArrayRef = sc.Input[0]; if (sc.SetDefaults) { // Set the configuration and defaults sc.GraphName = "Test Sequence of Study Evaluation B"; sc.CalculationPrecedence = LOW_PREC_LEVEL; sc.AutoLoop = true; sc.GraphRegion = 0; sc.ValueFormat = VALUEFORMAT_INHERITED; // Set the name of the first subgraph Subgraph_a.Name = "Index of bar"; Subgraph_a.DrawStyle = DRAWSTYLE_CUSTOM_VALUE_AT_Y; Subgraph_a.PrimaryColor = RGB(0, 255, 0); Subgraph_a.LineWidth = 10; Subgraph_a.DrawZeros = false; Input_AArrayRef.Name = "Study A reference"; Input_AArrayRef.SetStudyID(2); sc.ScaleRangeType = SCALE_SAMEASREGION; return; } int n = sc.Index; SCFloatArray indexArray; if (sc.GetStudyArrayUsingID(Input_AArrayRef.GetStudyID(), 0, indexArray) > 0 && indexArray.GetArraySize() > 0); if (sc.GetBarHasClosedStatus() == BHCS_BAR_HAS_CLOSED) { //Copy the study data that we retrieved using GetStudyArrayUsingID, into a subgraph data output array Subgraph_a.Arrays[0][n] = sc.Low[n] - 2 * sc.TickSize; Subgraph_a[n] = (float)indexArray[n]; } } |
