Login Page - Create Account

Support Board


Date/Time: Sat, 27 Apr 2024 00:17:30 +0000



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

[2019-03-09 14:38:06]
TedMar - Posts: 189
@Ackin in your Example colorred GetPersistentInt counted RedBars. How is best way to remeber RedBarsseries and Last.Price for later calculation in an Array?

in my added lines in u example i use a subgraphArrey for store data, and i compare Last Array with current one

SCSFExport scsf_ExampleArrayCount(SCStudyInterfaceRef sc)
{
  SCSubgraphRef Graph1 = sc.Subgraph[0];
  SCSubgraphRef Graph2 = sc.Subgraph[1];

  if (sc.SetDefaults)
  {
    sc.GraphName = "Example Array Cont ";
    sc.StudyDescription = "Count RED Bars ArraySeries";
    sc.AutoLoop = 1;
    sc.GraphRegion = 0;

    Graph1.Name = "Graph1";
    Graph1.DrawStyle = DRAWSTYLE_ARROW_DOWN;
    Graph1.LineWidth = 3;
    Graph1.PrimaryColor = RGB(255, 51, 255);

    Graph2.Name = "Graph2";
    Graph2.DrawStyle = DRAWSTYLE_POINT_ON_LOW;
    Graph2.LineWidth = 3;
    Graph2.PrimaryColor = COLOR_BLUE;

    return;
  }
  SCString message;
  
  SCFloatArray myArray = sc.Subgraph[2].Arrays[0]; // SubgraphArrey [2] for Calculate only

  int& colorred = sc.GetPersistentInt(1);

  if (sc.GetBarHasClosedStatus(sc.Index) == BHCS_BAR_HAS_CLOSED)
  {

    if (sc.Close[sc.Index] < sc.Open[sc.Index])
    { //without DOJI

        colorred += 1;
    }
    else {colorred = 0;  }
        
    if ((colorred) >= 4)
    {
      for (int i = 0; i < (colorred); i++)
      {
        Graph1[sc.Index - (i)] = sc.High[sc.Index - (i)];
      }

      myArray[sc.Index] = sc.Close[sc.Index];

      if (myArray[sc.Index] < myArray[sc.Index - 1]) // Comapre Prices from last RedBarSeries
      {
        Graph2[sc.Index] = myArray[sc.Index];
      }
      message.Format("Array %i ", myArray.GetArraySize());
      sc.AddMessageToLog(message, 1);
    }
    
  }
}


is posible to resolve this comapre without subgraph array ? maybe with vector or other array type include sc.BaseData?



Please leve me example if u know.. THX
Date Time Of Last Edit: 2019-03-09 21:04:22