Login Page - Create Account

Support Board


Date/Time: Sun, 19 May 2024 13:52:11 +0000



Post From: plot multiple subgraphs to different regions from single study

[2020-10-31 04:06:53]
jomo88 - Posts: 47
For anyone looking, you can find the following code from Studies2.cpp, it works well. Also, good info is at Referencing Other Time Frames and Symbols When Using the ACSIL



#include "sierrachart.h"
SCDLLName("StudySubgraphReference")
SCSFExport scsf_StudySubgraphReference(SCStudyInterfaceRef sc)
{
  SCSubgraphRef Subgraph_StudySubgraphReference = sc.Subgraph[0];

  SCInputRef Input_StudySubgraphReference = sc.Input[0];
  SCInputRef Input_DrawZeros = sc.Input[1];

  // Set configuration variables

  if (sc.SetDefaults)
  {
    sc.GraphName = "Study Subgraph Reference";
    sc.GraphRegion = 2;

    sc.ScaleRangeType = SCALE_AUTO;

    Subgraph_StudySubgraphReference.Name = "Study Subgraph";
    Subgraph_StudySubgraphReference.DrawStyle = DRAWSTYLE_LINE;
    Subgraph_StudySubgraphReference.PrimaryColor = RGB(0, 255, 0);

    Input_StudySubgraphReference.Name = "Study Subgraph to Reference";
    Input_StudySubgraphReference.SetStudySubgraphValues(0, 0);

    Input_DrawZeros.Name = "Draw Zeros";
    Input_DrawZeros.SetYesNo(true);
    
    sc.CalculationPrecedence = VERY_LOW_PREC_LEVEL;

    sc.AutoLoop = 0;

    return;
  }


  // Do data processing
  Subgraph_StudySubgraphReference.DrawZeros = Input_DrawZeros.GetYesNo();

  //This will return sc.UpdateStartIndex or an earlier index if this study is calculated after a study which calculated at an earlier index and supports setting that earlier index.
  int ActualStartIndex = sc.GetCalculationStartIndexForStudy();

  // Get the array for the specified Input Data from the specified studies
  SCFloatArray Study1Array;
  sc.GetStudyArrayUsingID(Input_StudySubgraphReference.GetStudyID(), Input_StudySubgraphReference.GetSubgraphIndex(), Study1Array);

  for (int BarIndex = ActualStartIndex; BarIndex < sc.ArraySize; BarIndex++)
  {
    Subgraph_StudySubgraphReference[BarIndex] = Study1Array[BarIndex];
  }

  sc.EarliestUpdateSubgraphDataArrayIndex = ActualStartIndex;
}