Login Page - Create Account

Support Board


Date/Time: Sun, 04 Dec 2022 21:34:50 +0000



Stochastic Momentum source code

View Count: 138

[2022-10-01 19:01:41]
User203192 - Posts: 14
Anyone know where to get the Stochastic Momentum source code or at least a relative build on it in C++?
[2022-10-02 08:34:59]
JohnR - User831573 - Posts: 225
You might try here

C:\SierraChart\ACS_Source\Studies8.cpp (49 hits)
  Line 5310: SCSFExport scsf_StochasticMomentumIndicator(SCStudyInterfaceRef sc)

Hope this helps,
JohnR
[2022-10-02 17:42:10]
User203192 - Posts: 14
Nothing does up when I click that into the browser? It brings me to a google search? If I search the ACS_Source folder it comes up as zero in the search. Tried a couple different name tittle as well?
[2022-10-02 17:52:36]
Ackin - Posts: 1840

SCSFExport scsf_StochasticMomentumIndicator(SCStudyInterfaceRef sc)
{
  SCSubgraphRef Subgraph_SMI = sc.Subgraph[0];
  SCSubgraphRef Subgraph_AvgSMI = sc.Subgraph[1];
  SCSubgraphRef Subgraph_Overbought = sc.Subgraph[2];
  SCSubgraphRef Subgraph_Oversold = sc.Subgraph[3];

  SCInputRef Input_OverboughtInput = sc.Input[0];
  SCInputRef Input_OversoldInput = sc.Input[1];
  SCInputRef Input_PercentDLength = sc.Input[2];
  SCInputRef Input_PercentKLength = sc.Input[3];
  SCInputRef Input_ExpMovAvgLength = sc.Input[4];

  if (sc.SetDefaults)
  {
    sc.GraphName = "Stochastic Momentum Indicator";
    sc.StudyDescription = "Stochastic Momentum Indicator";

    
    sc.GraphRegion = 1;
    sc.AutoLoop = 1;

    Subgraph_SMI.Name = "SMI";
    Subgraph_SMI.DrawStyle = DRAWSTYLE_LINE;
    Subgraph_SMI.PrimaryColor = RGB(0,255,0);
    Subgraph_SMI.DrawZeros = false;

    Subgraph_AvgSMI.Name = "SMI Average";
    Subgraph_AvgSMI.DrawStyle = DRAWSTYLE_LINE;
    Subgraph_AvgSMI.PrimaryColor = RGB(255,0,255);
    Subgraph_AvgSMI.DrawZeros = false;

    Subgraph_Overbought.Name = "Overbought";
    Subgraph_Overbought.DrawStyle = DRAWSTYLE_LINE;
    Subgraph_Overbought.PrimaryColor = RGB(255,255,0);
    Subgraph_Overbought.DrawZeros = false;

    Subgraph_Oversold.Name = "Oversold";
    Subgraph_Oversold.DrawStyle = DRAWSTYLE_LINE;
    Subgraph_Oversold.PrimaryColor = RGB(255,127,0);
    Subgraph_Oversold.DrawZeros = false;

    Input_OverboughtInput.Name = "Overbought Value";
    Input_OverboughtInput.SetFloat(40.0f);

    Input_OversoldInput.Name = "Oversold Value";
    Input_OversoldInput.SetFloat(-40.0f);

    Input_PercentDLength.Name = "%D Length";
    Input_PercentDLength.SetInt(3);

    Input_PercentKLength.Name = "%K Length";
    Input_PercentKLength.SetInt(5);

    Input_ExpMovAvgLength.Name = "EMA Length";
    Input_ExpMovAvgLength.SetInt(3);

    return;
  }


  sc.DataStartIndex = max(Input_PercentKLength.GetInt(), Input_PercentDLength.GetInt());

  if (sc.Index < sc.DataStartIndex)
    return;

  SCFloatArrayRef TempLowest = Subgraph_SMI.Arrays[0];
  SCFloatArrayRef TempHighest = Subgraph_SMI.Arrays[1];
  SCFloatArrayRef TempRelDiff = Subgraph_SMI.Arrays[2];
  SCFloatArrayRef TempDiff = Subgraph_SMI.Arrays[3];
  SCFloatArrayRef TempAvgRelMA = Subgraph_SMI.Arrays[4];
  SCFloatArrayRef TempAvgRel = Subgraph_SMI.Arrays[5];
  SCFloatArrayRef TempAvgDiffMA = Subgraph_SMI.Arrays[6];
  SCFloatArrayRef TempAvgDiff = Subgraph_SMI.Arrays[7];

  sc.Lowest(sc.Low, TempLowest, Input_PercentKLength.GetInt());
  sc.Highest(sc.High, TempHighest, Input_PercentKLength.GetInt());

  TempRelDiff[sc.Index] = sc.Close[sc.Index] - (TempHighest[sc.Index] + TempLowest[sc.Index]) / 2.0f;
  TempDiff[sc.Index] = TempHighest[sc.Index] - TempLowest[sc.Index];

  sc.ExponentialMovAvg(TempRelDiff, TempAvgRelMA, Input_PercentDLength.GetInt());
  sc.ExponentialMovAvg(TempAvgRelMA, TempAvgRel, Input_PercentDLength.GetInt());
  sc.ExponentialMovAvg(TempDiff, TempAvgDiffMA, Input_PercentDLength.GetInt());
  sc.ExponentialMovAvg(TempAvgDiffMA, TempAvgDiff, Input_PercentDLength.GetInt());

  if (TempAvgDiff[sc.Index] != 0.0f)
    Subgraph_SMI[sc.Index] = TempAvgRel[sc.Index] / (TempAvgDiff[sc.Index] / 2.0f) * 100.0f;
  else
    Subgraph_SMI[sc.Index] = 0.0f;

  sc.ExponentialMovAvg(Subgraph_SMI, Subgraph_AvgSMI, Input_ExpMovAvgLength.GetInt());

  Subgraph_Overbought[sc.Index] = Input_OverboughtInput.GetFloat();
  Subgraph_Oversold[sc.Index] = Input_OversoldInput.GetFloat();
}


[2022-10-02 17:55:23]
User203192 - Posts: 14
Thank you!!
[2022-10-02 23:36:29]
Sierra_Chart Engineering - Posts: 5464
For further information, refer to:
How to Build an Advanced Custom Study from Source Code: Searching for Source Code for Sierra_Chart Built-In Studies
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, use the Teton service:
Sierra Chart Teton Futures Order Routing
Date Time Of Last Edit: 2022-10-02 23:50:17

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

Login

Login Page - Create Account