Login Page - Create Account

Support Board


Date/Time: Thu, 13 Feb 2025 03:11:16 +0000



Post From: Linear Regression function in ACSIL

[2020-11-17 10:56:51]
Ackin - Posts: 1865
How to Build an Advanced Custom Study from Source Code: Searching for Source Code for Sierra Chart Built-In Studies



Studies3.cpp

SCSFExport scsf_MovingLinearRegressionLine(SCStudyInterfaceRef sc)
{
  SCSubgraphRef Subgraph_MLR = sc.Subgraph[0];

  SCInputRef Input_InputData = sc.Input[0];
  SCInputRef Input_Length = sc.Input[2];

  if(sc.SetDefaults)
  {
    sc.GraphName = "Moving Linear Regression";

    sc.GraphRegion = 0;
    sc.ValueFormat = 3;
    sc.AutoLoop = 1;

    Subgraph_MLR.Name = "MLR";
    Subgraph_MLR.DrawStyle = DRAWSTYLE_LINE;
    Subgraph_MLR.PrimaryColor = RGB(0,255,0);
    Subgraph_MLR.DrawZeros = false;
    
    Input_InputData.Name = "Input Data";
    Input_InputData.SetInputDataIndex(SC_LAST);
    
    Input_Length.Name = "Length";
    Input_Length.SetInt(14);
    Input_Length.SetIntLimits(1, MAX_STUDY_LENGTH);


    
    

    return;
  }

  sc.DataStartIndex = Input_Length.GetInt()-1;  
  
  sc.LinearRegressionIndicator(sc.BaseDataIn[Input_InputData.GetInputDataIndex()], Subgraph_MLR, Input_Length.GetInt());    
}