Login Page - Create Account

Support Board


Date/Time: Sun, 19 May 2024 22:32:13 +0000



Post From: ACSIL - WilliamsR

[2018-02-28 22:51:54]
JoseyWales - Posts: 67
Here is the code for Williams %R, found in file ACS_Source\studies5.cpp

SCSFExport scsf_WilliamsR(SCStudyInterfaceRef sc)
{
  SCSubgraphRef PercentR = sc.Subgraph[0];

  SCInputRef Length = sc.Input[3];
  SCInputRef Invert = sc.Input[4];
  SCInputRef InputDataHigh = sc.Input[5];
  SCInputRef InputDataLow = sc.Input[6];
  SCInputRef InputDataLast = sc.Input[7];
  SCInputRef UpdateFlag = sc.Input[8];

  if(sc.SetDefaults)  
  {
    sc.GraphName = "Williams %R";

    sc.GraphRegion= 1;
    sc.ValueFormat = 2;

    PercentR.Name = "%R";
    PercentR.DrawZeros = true;
    PercentR.DrawStyle = DRAWSTYLE_LINE;
    PercentR.PrimaryColor = RGB(0,255,0);

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

    Invert.Name = "Invert Output";
    Invert.SetYesNo(1);

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

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

    InputDataLast.Name = "Input Data for Last";
    InputDataLast.SetInputDataIndex(SC_LAST);

    UpdateFlag.SetInt(1); //update flag

    sc.AutoLoop = 1;


    //During development set this flag to 1, so the DLL can be modified. When development is completed, set it to 0 to improve performance.
    sc.FreeDLL = 0;


    return;
  }

  if (UpdateFlag.GetInt() == 0)
  {
    InputDataHigh.SetInputDataIndex(SC_HIGH);
    InputDataLow.SetInputDataIndex(SC_LOW);
    InputDataLast.SetInputDataIndex(SC_LAST);
    UpdateFlag.SetInt(1);
  }

  sc.DataStartIndex = Length.GetInt();

  sc.WilliamsR(
    sc.BaseData[InputDataHigh.GetInputDataIndex()],
    sc.BaseData[InputDataLow.GetInputDataIndex()],
    sc.BaseData[InputDataLast.GetInputDataIndex()],
    PercentR,
    sc.Index,
    Length.GetInt()
    );

  if (Invert.GetYesNo())
    PercentR[sc.Index] *= -1;
}