Login Page - Create Account

Support Board


Date/Time: Sun, 19 May 2024 08:29:32 +0000



Post From: Change Line width for threshold with ACSIL

[2020-08-25 22:41:33]
Ackin - Posts: 1865
Simple MA example


SCSFExport scsf_MovingAverageSimple(SCStudyInterfaceRef sc)
{
  SCSubgraphRef Subgraph_Avg = sc.Subgraph[0];
  SCSubgraphRef Subgraph_Avg2 = sc.Subgraph[1];

  SCInputRef Input_Data = sc.Input[0];
  SCInputRef Input_Length = sc.Input[1];
  SCInputRef Userval = sc.Input[2];

  if (sc.SetDefaults)
  {
    sc.GraphName = "Moving Average - Simple";

    sc.GraphRegion = 1;
    sc.ValueFormat = 2;
    sc.AutoLoop = 1;

    Subgraph_Avg.Name = "Avg";
    Subgraph_Avg.DrawStyle = DRAWSTYLE_LINE;
    Subgraph_Avg.PrimaryColor = RGB(0, 0, 255);
    Subgraph_Avg.LineWidth = 1;
    Subgraph_Avg.DrawZeros = true;

    Subgraph_Avg2.Name = "Avg2";
    Subgraph_Avg2.DrawStyle = DRAWSTYLE_LINE_SKIP_ZEROS;
    Subgraph_Avg2.PrimaryColor = RGB(255, 255, 0);
    Subgraph_Avg2.LineWidth = 5;
    Subgraph_Avg2.DrawZeros = 0;

    Input_Data.Name = "Input Data";
    Input_Data.SetInputDataIndex(SC_VOLUME);

    Input_Length.Name = "Length";
    Input_Length.SetInt(5);
    Input_Length.SetIntLimits(1, MAX_STUDY_LENGTH);

    Userval.Name = "User Value";
    Userval.SetFloat(4500.0f);


    return;
  }

  sc.DataStartIndex = Input_Length.GetInt() - 1;

  sc.SimpleMovAvg(sc.BaseDataIn[Input_Data.GetInputDataIndex()], Subgraph_Avg, Input_Length.GetInt());
  if (Subgraph_Avg[sc.Index] > Userval.GetFloat()) {
    Subgraph_Avg2[sc.Index] = Subgraph_Avg[sc.Index];
  }
  else {
    Subgraph_Avg2[sc.Index] = 0;
  }
}