Login Page - Create Account

Support Board


Date/Time: Wed, 12 Feb 2025 21:01:00 +0000



Linear Regression function in ACSIL

View Count: 1736

[2017-02-20 17:32:22]
User71961 - Posts: 144
the function sc.LinearRegressionIndicator() documentation is pretty sparse

http://www.sierrachart.com/index.php?page=doc/ACSIL_Members_Functions.html#scLinearRegressionIndicator

is there a page with more detail on how to use this function?
i'm going to need to iteratively calculate a regression over a data set, as an intermediary step in my custom study...but i don't see the detailed documentation that i need to help with this.

Also, is there a multi-factor regression function available in the sc functions?
[2017-02-20 18:41:48]
Sierra Chart Engineering - Posts: 104368
The documentation has been updated along with a link to the study which includes detailed formulas:
http://www.sierrachart.com/index.php?page=doc/ACSIL_Members_Functions.html#scLinearRegressionIndicator

There are several examples showing exactly how to use it.

When this function is called at each chart bar, it does calculate the Moving Average-Least Squares/Linear Regression.

Sierra Chart does not have a multi factor linear regression function but maybe you can make that from the source code we provide. Have a look at the CalculateRegressionStatistics function in the /ACS_Source/SCStudyFunctions.cpp file.
Sierra Chart Support - Engineering Level

Your definitive source for support. Other responses are from users. Try to keep your questions brief and to the point. Be aware of support policy:
https://www.sierrachart.com/index.php?l=PostingInformation.php#GeneralInformation

For the most reliable, advanced, and zero cost futures order routing, *change* to the Teton service:
Sierra Chart Teton Futures Order Routing
Date Time Of Last Edit: 2017-02-20 18:42:17
[2020-11-17 07:23:09]
ycomp - Posts: 321
how would I plot a linear regression moving average using 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());    
}


[2020-11-17 17:36:07]
SC Support Tom - Posts: 450
WRT Post #3:


how would I plot a linear regression moving average using ACSIL?

Sierra Chart has a built-in study that accomplishes this, namely Moving Average - Linear Regression.

Moving Linear Regression / Moving Average - Linear Regression

You can add the study to the chart by following these instructions:

Chart Studies: Adding/Modifying Chart Studies

To post a message in this thread, you need to log in with your Sierra Chart account:

Login

Login Page - Create Account