Login Page - Create Account

Support Board


Date/Time: Thu, 26 Sep 2024 23:31:03 +0000



sc.RangeBarValue

View Count: 477

[2020-10-07 13:21:46]
jsob - Posts: 34
I am not a software engineer. I've been using this structure member for years to retrieve the value of the setting for range bar periods. I would very much appreciate some sample code that I can build on so that my code again works. Thank you.
[2020-10-07 14:22:57]
Ackin - Posts: 1865
sc.RangeBarValue

This ACSIL structure member is considered out of date/deprecated. Instead use the sc.GetBarPeriodParameters and sc.SetBarPeriodParameters functions.

sc.GetBarPeriodParameters
sc.GetBarPeriodParameters()

sc.SetBarPeriodParameters
sc.SetBarPeriodParameters()






********************************************************************
CCIPredictor Example (from Studies4.cpp ACS folder in your Sierrachart):

Old code

SCSFExport scsf_CCIPredictor(SCStudyInterfaceRef sc)
{
  SCSubgraphRef CCIProjHigh = sc.Subgraph[0];
  SCSubgraphRef CCIProjLow = sc.Subgraph[1];
  SCSubgraphRef CCIOutputHigh = sc.Subgraph[2];
  SCSubgraphRef CCIOutputLow = sc.Subgraph[3];


  SCInputRef CCILength = sc.Input[0];

  if (sc.SetDefaults)
  {
    // Set the configuration and defaults

    sc.GraphName = "CCI Predictor";

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

    CCIProjHigh.Name = "CCI Proj High";
    CCIProjHigh.DrawStyle = DRAWSTYLE_ARROWDOWN;
    CCIProjHigh.PrimaryColor = RGB(255,255,255);
    CCIProjHigh.LineWidth = 3;
    CCIProjHigh.DrawZeros = false;

    CCIProjLow.Name = "CCI Proj Low";
    CCIProjLow.DrawStyle = DRAWSTYLE_ARROWUP;
    CCIProjLow.PrimaryColor = RGB(255,255,255);
    CCIProjLow.LineWidth = 3;
    CCIProjLow.DrawZeros = false;

    CCILength.Name = "CCI Length";
    CCILength.SetInt(14);

    return;
  }


  //CCI High
  CCIProjHigh.Arrays[0][sc.Index] = sc.HLCAvg[sc.Index];

  if (sc.Index == sc.ArraySize - 1 && sc.AreRangeBars())
  {
    float ProjectedRangeHigh=sc.Low[sc.Index]+sc.RangeBarValue;
    CCIProjHigh.Arrays[0][sc.Index] = ( ProjectedRangeHigh + ProjectedRangeHigh +sc.Low[sc.Index])/3;

  }

  sc.CCI(CCIProjHigh.Arrays[0], CCIOutputHigh, sc.Index, CCILength.GetInt(), 0.015f);

  if (sc.Index == sc.ArraySize - 1)
    CCIProjHigh[sc.Index] = CCIOutputHigh[sc.Index];
  else
    CCIProjHigh[sc.Index] = 0;



  //CCI Low
  CCIProjLow.Arrays[0][sc.Index] = sc.HLCAvg[sc.Index];
  if (sc.Index == sc.ArraySize - 1 && sc.AreRangeBars())
  {
    float ProjectedRangeLow=sc.High[sc.Index]-sc.RangeBarValue;
    CCIProjLow.Arrays[0][sc.Index] = ( ProjectedRangeLow + ProjectedRangeLow +sc.High[sc.Index])/3;


  }

  sc.CCI(CCIProjLow.Arrays[0], CCIOutputLow, sc.Index, CCILength.GetInt(), 0.015f);

  if (sc.Index == sc.ArraySize - 1)
    CCIProjLow[sc.Index] = CCIOutputLow[sc.Index];
  else
    CCIProjLow[sc.Index] = 0;


}

New code

SCSFExport scsf_CCIPredictor(SCStudyInterfaceRef sc)
{
  SCSubgraphRef CCIProjHigh = sc.Subgraph[0];
  SCSubgraphRef CCIProjLow = sc.Subgraph[1];
  SCSubgraphRef CCIOutputHigh = sc.Subgraph[2];
  SCSubgraphRef CCIOutputLow = sc.Subgraph[3];


  SCInputRef CCILength = sc.Input[0];

  if (sc.SetDefaults)
  {
    // Set the configuration and defaults

    sc.GraphName = "CCI Predictor";

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

    CCIProjHigh.Name = "CCI Proj High";
    CCIProjHigh.DrawStyle = DRAWSTYLE_ARROW_DOWN;
    CCIProjHigh.PrimaryColor = RGB(255,255,255);
    CCIProjHigh.LineWidth = 3;
    CCIProjHigh.DrawZeros = false;

    CCIProjLow.Name = "CCI Proj Low";
    CCIProjLow.DrawStyle = DRAWSTYLE_ARROW_UP;
    CCIProjLow.PrimaryColor = RGB(255,255,255);
    CCIProjLow.LineWidth = 3;
    CCIProjLow.DrawZeros = false;

    CCILength.Name = "CCI Length";
    CCILength.SetInt(14);

    return;
  }

  n_ACSIL::s_BarPeriod BarPeriod;
  sc.GetBarPeriodParameters(BarPeriod);

  for(int BarIndex = sc.UpdateStartIndex; BarIndex < sc.ArraySize; BarIndex++)
  {
    //CCI High
    CCIProjHigh.Arrays[0][BarIndex] = sc.HLCAvg[BarIndex];

    if (BarIndex == sc.ArraySize - 1 && BarPeriod.AreRangeBars())
    {
      float ProjectedRangeHigh = sc.Low[BarIndex] + BarPeriod.IntradayChartBarPeriodParameter1;
      CCIProjHigh.Arrays[0][BarIndex] = (ProjectedRangeHigh + ProjectedRangeHigh + sc.Low[BarIndex]) / 3;

    }

    sc.CCI(CCIProjHigh.Arrays[0], CCIOutputHigh, BarIndex, CCILength.GetInt(), 0.015f);

    if (BarIndex == sc.ArraySize - 1)
      CCIProjHigh[BarIndex] = CCIOutputHigh[BarIndex];
    else
      CCIProjHigh[BarIndex] = 0;


    //CCI Low
    CCIProjLow.Arrays[0][BarIndex] = sc.HLCAvg[BarIndex];
    if (BarIndex == sc.ArraySize - 1 && BarPeriod.AreRangeBars())
    {
      float ProjectedRangeLow = sc.High[BarIndex] - BarPeriod.IntradayChartBarPeriodParameter1;
      CCIProjLow.Arrays[0][BarIndex] = (ProjectedRangeLow + ProjectedRangeLow + sc.High[BarIndex]) / 3;
    }

    sc.CCI(CCIProjLow.Arrays[0], CCIOutputLow, BarIndex, CCILength.GetInt(), 0.015f);

    if (BarIndex == sc.ArraySize - 1)
      CCIProjLow[BarIndex] = CCIOutputLow[BarIndex];
    else
      CCIProjLow[BarIndex] = 0;
  }


}

[2020-10-07 14:43:27]
jsob - Posts: 34
Thank you, kindly. After I took a deep breath, I found the code you indicate and updated. Much appreciated!

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

Login

Login Page - Create Account