Support Board
Date/Time: Sun, 24 Nov 2024 15:01:23 +0000
Post From: Slow loading Study that retrieves an external subgraph array
[2024-06-04 19:33:03] |
ycomp - Posts: 318 |
this is not my full code, but it is the important part that shows what I'm trying to do. On autoloop it works fine (but very slow loading) with Autoloop off, it only paints bars going forward // Section 1 - Set the configuration variables and defaults if (sc.SetDefaults) { sc.AutoLoop = 0; //Automatic looping is disabled. Subgraph_External.Name = "External Subgraph"; Subgraph_External.LineWidth = 1; Subgraph_External.DrawStyle = DRAWSTYLE_IGNORE; Subgraph_External.PrimaryColor = COLOR_DODGERBLUE; Subgraph_External.SecondaryColorUsed = false; Subgraph_External.DisplayNameValueInWindowsFlags = 1; // External Study Subgraph Input_UseExternalStudy.Name = "Use External Study Subgraph for the comparison value? (no=use Moving Average)"; Input_UseExternalStudy.SetYesNo(true); Input_SubgraphRef.Name = "External Study Subgraph Reference"; Input_SubgraphRef.SetStudySubgraphValues(0, 0); return; } /*** Actual Processing ***/ const int BarIndex = sc.AutoLoop ? sc.Index : sc.ArraySize - 1; double value; if (Input_UseExternalStudy.GetYesNo()) { // Retrieve the external study subgraph array sc.GetStudyArrayUsingID(Input_SubgraphRef.GetStudyID(), Input_SubgraphRef.GetSubgraphIndex(), Subgraph_External.Data); value = Subgraph_External[BarIndex]; } else { value = // alternate calculation without subgraph } if I try to add a for loop with autoloop off like from the docs for (int Index = sc.UpdateStartIndex; Index < sc.ArraySize; Index++) { int BarIndex = Index; // double value and rest of code below it is in the loop now then it will hang while drawing the chart. 1) How can I write this code with autoloop off so that it paints all bars? 2) How can I optimize the code so that it is not really slow loading? is there a better way than to retrieve the subgraph array every time? |