Login Page - Create Account

Support Board


Date/Time: Fri, 26 Apr 2024 20:44:41 +0000



Post From: ACSIL: simple FOR loop , very long reload and recalculate time

[2019-02-26 16:16:50]
TedMar - Posts: 189
Hi, in my Example, try simple FOR loop. BUT this example "reload and recalculate" 26 secunds on 1 Day History and period 5 minutes chart. Whats wrong?



SCSFExport scsf_ExampleForCount(SCStudyInterfaceRef sc)
{
  SCSubgraphRef Graph1 = sc.Subgraph[0];
  if (sc.SetDefaults)    
  {
    sc.GraphName = "Example Count 4 Red Bars ";
    sc.StudyDescription = "Count RED Bars Serries in Manual loop";
    sc.AutoLoop = 0;
    sc.GraphRegion = 0;
  
    Graph1.Name = "Graph1";
    Graph1.DrawStyle = DRAWSTYLE_ARROW_DOWN;
    Graph1.LineWidth = 3;
    Graph1.PrimaryColor = RGB(255, 51, 255);

    return;
  }


  for (int BarIndex = sc.UpdateStartIndex; BarIndex < sc.ArraySize; BarIndex++) //Manual Loop
  {

    
    if (sc.Close[BarIndex] < sc.Open[BarIndex]) // find REDBAR
    {
      int REDCount = 1;
      for (int i = REDCount; sc.Close[BarIndex - (REDCount)] < sc.Open[BarIndex - (REDCount)]; i++) //Count RedBars serie,this loop needs 26s for chart Reload 5m Chart on Intel i5 3,3Mhz

      {
        REDCount++;
      }
      
      if (REDCount >= 4)
      {
        for (int i = 0; i < REDCount; i++)
        {
          Graph1[BarIndex - (i)] = sc.High[BarIndex - (i)];
        }

      }    
    }
  }
}




v1879
Date Time Of Last Edit: 2019-02-26 16:22:38