Login Page - Create Account

Support Board


Date/Time: Sun, 16 Mar 2025 08:16:15 +0000



Post From: Rename and Compile an Existing SC Study for Distribution

[2022-08-05 06:36:17]
User429065 - Posts: 128
In an effort to protect a proprietary combination of studies within the "Study Subgraphs Average - Multiple" study, I'm renaming it within the code using Notepad++, then trying to compile it using SC Remote or Visual Studio. Eventually, I'll protect it with a password. After several hours of following the "step-by-step instructions", I'm still not getting the required DLL file (see the attached result). Please advise, thank you very much!


#include "sierrachart.h"
#include "scstudyfunctions.h"

SCSFExport scsf_TrendeX(SCStudyInterfaceRef sc)
{
  SCSubgraphRef Subgraph_Average = sc.Subgraph[0];
  SCFloatArrayRef Array_SubgraphCount = sc.Subgraph[0].Arrays[0];

  if (sc.SetDefaults)
  {
    sc.GraphName = "TrendeX";

    sc.ValueFormat = 3;
    sc.AutoLoop = 0;//manual looping

    sc.CalculationPrecedence = LOW_PREC_LEVEL;

    Subgraph_Average.Name = "TrendeX";
    Subgraph_Average.DrawStyle = DRAWSTYLE_LINE;
    Subgraph_Average.LineWidth = 2;
    Subgraph_Average.PrimaryColor = RGB(0, 255, 0);
    Subgraph_Average.DrawZeros = false;

    int StudyReferenceIndex = 0;

    for (int InputIndex = 0; InputIndex < 40; InputIndex += 2)
    {
      StudyReferenceIndex++;
      sc.Input[InputIndex].Name.Format("Use Study Subgraph Reference %d", StudyReferenceIndex);
      sc.Input[InputIndex].SetYesNo(false);

      sc.Input[InputIndex + 1].Name.Format("Study Subgraph Reference %d", StudyReferenceIndex);
      sc.Input[InputIndex + 1].SetStudySubgraphValues(0, 0);

    }

    return;
  }

  int NumberUsedSubgraphs = 0;


  int CalculationStartIndex = sc.GetCalculationStartIndexForStudy();
  sc.EarliestUpdateSubgraphDataArrayIndex = CalculationStartIndex;

  for (int SubgraphIndex = 0; SubgraphIndex < 20; SubgraphIndex++)
  {
    if (!sc.Input[SubgraphIndex * 2].GetYesNo())
      continue;

    SCFloatArray StudyArray;
    sc.GetStudyArrayUsingID(sc.Input[SubgraphIndex * 2 + 1].GetStudyID(), sc.Input[SubgraphIndex * 2 + 1].GetSubgraphIndex(), StudyArray);

    if (StudyArray.GetArraySize() == 0)
      continue;

    NumberUsedSubgraphs++;

    for (int BarIndex = CalculationStartIndex; BarIndex < sc.ArraySize; BarIndex++)
    {
      if (NumberUsedSubgraphs == 1)
      {
        Subgraph_Average[BarIndex] = 0;
        Array_SubgraphCount[BarIndex] = 0;
      }

      //If the input subgraph is zero at this bar index, then do not include it in the average.
      if (StudyArray[BarIndex] == 0)
        continue;
      
      Subgraph_Average[BarIndex] += StudyArray[BarIndex];
      Array_SubgraphCount[BarIndex] += 1;
    }
  }

  for (int BarIndex = CalculationStartIndex; BarIndex < sc.ArraySize; BarIndex++)
  {
    if(Array_SubgraphCount[BarIndex] != 0)
      Subgraph_Average[BarIndex] /= Array_SubgraphCount[BarIndex];

  }  
}
Date Time Of Last Edit: 2022-08-05 06:38:36
imageBuild DLL.JPG / V - Attached On 2022-08-05 06:16:40 UTC - Size: 38.97 KB - 119 views