Login Page - Create Account

Support Board


Date/Time: Wed, 27 Nov 2024 19:28:17 +0000



Post From: Does this code serve any purpose?

[2014-09-26 11:58:42]
David_M - Posts: 14
I'm trying to learn the SC language and I can't see the purpose of the 'Unused' and 'Version' InputRef. The output seems to be the same when these lines are commented out, or included. Am I missing something?
Thanks

SCSFExport scsf_HighestHighLowestLowOverNBars(SCStudyInterfaceRef sc)
{
  SCSubgraphRef HighestHigh = sc.Subgraph[0];
  SCSubgraphRef LowestLow = sc.Subgraph[1];

  SCInputRef Length = sc.Input[3];
  //SCInputRef Unused = sc.Input[4];
  SCInputRef InputDataHigh = sc.Input[5];
  SCInputRef InputDataLow = sc.Input[6];
  //SCInputRef Version = sc.Input[7];

  if (sc.SetDefaults)
  {
    sc.GraphName = "Highest High / Lowest Low Over N Bars";

    sc.GraphRegion = 0;
    sc.AutoLoop = 1;
    sc.FreeDLL = 1;
    
    HighestHigh.Name= "Highest High";
    HighestHigh.DrawStyle = DRAWSTYLE_LINE;
    HighestHigh.PrimaryColor = RGB(0,255,0);
    HighestHigh.DrawZeros = true;

    LowestLow.Name = "Lowest Low";
    LowestLow.DrawStyle = DRAWSTYLE_LINE;
    LowestLow.PrimaryColor = RGB(255,0,255);
    LowestLow.DrawZeros = true;

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

    InputDataHigh.Name = "Input Data High";
    InputDataHigh.SetInputDataIndex(SC_HIGH);

    InputDataLow.Name = "Input Data Low";
    InputDataLow.SetInputDataIndex(SC_LOW);

    //Version.SetYesNo(1);

    return;
  }

  //if(Version.GetYesNo() == 0)
  //{
  //  InputDataHigh.SetInputDataIndex(SC_HIGH);
  //  InputDataLow.SetInputDataIndex(SC_LOW);
  //  Version.SetYesNo(1);
  //}

  sc.DataStartIndex = (int)(Length.GetInt()) - 1; //+ Unused.GetFloat());

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

  double Lowest = FLT_MAX;
  double Highest = -FLT_MAX;
  for(int i1 = sc.Index - (Length.GetInt() - 1); i1<= sc.Index; i1++)
  {
    if(Highest < sc.BaseDataIn[InputDataHigh.GetInputDataIndex()][i1])
      Highest = sc.BaseDataIn[InputDataHigh.GetInputDataIndex()][i1];

    if(Lowest > sc.BaseDataIn[InputDataLow.GetInputDataIndex()][i1])
      Lowest = sc.BaseDataIn[InputDataLow.GetInputDataIndex()][i1];
  }

  HighestHigh[sc.Index] = (float)Highest;
  LowestLow[sc.Index] = (float)Lowest;
}
Date Time Of Last Edit: 2014-09-26 18:52:27