Login Page - Create Account

Support Board


Date/Time: Sun, 22 Dec 2024 18:02:08 +0000



Post From: IsCustomChart = 1

[2015-02-08 01:23:52]
QnReally - Posts: 181
SCSFExport scsf_BaseGraphDisplacement(SCStudyInterfaceRef sc)
{
  SCSubgraphRef Open = sc.Subgraph[0];
  SCSubgraphRef High = sc.Subgraph[1];
  SCSubgraphRef Low = sc.Subgraph[2];
  SCSubgraphRef Last = sc.Subgraph[3];
  SCSubgraphRef Volume = sc.Subgraph[4];
  SCSubgraphRef OpenInterest = sc.Subgraph[5];
  SCSubgraphRef OHLCAvg = sc.Subgraph[6];
  SCSubgraphRef HLCAvg = sc.Subgraph[7];
  SCSubgraphRef HLAvg = sc.Subgraph[8];
  //SCSubgraphRef BidVol = sc.Subgraph[9];
  //  SCSubgraphRef AskVol = sc.Subgraph[10];
  SCInputRef GraphDisplacement = sc.Input[0];

  // Set configuration variables

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

    sc.GraphName = "BaseGraph Displacement Example";

    sc.StudyDescription = "This is an example of how to create a custom chart. This one is a copy of the BaseGraph.";

    // This member indicates that this is a custom chart study.
    //  This can only be set when SetDefaults is true.
    sc.IsCustomChart = 1; // true    
    sc.GraphRegion = 0; // First region    
    sc.DrawZeros = 0; // false    
    sc.GraphDrawType = GDT_OHLCBAR;
    sc.StandardChartHeader = 1; // true

    // Subgraphs

    Open.Name = "Open";
    Open.DrawStyle = DRAWSTYLE_LINE;

    High.Name = "High";
    High.DrawStyle = DRAWSTYLE_LINE;

    Low.Name = "Low";
    Low.DrawStyle = DRAWSTYLE_LINE;

    Last.Name = "Last";
    Last.DrawStyle = DRAWSTYLE_LINE;

    Volume.Name = "Volume";
    Volume.DrawStyle = DRAWSTYLE_IGNORE;

    OpenInterest.Name = "# of Trades / OI";
    OpenInterest.DrawStyle = DRAWSTYLE_IGNORE;

    OHLCAvg.Name = "OHLC Avg";
    OHLCAvg.DrawStyle = DRAWSTYLE_IGNORE;

    HLCAvg.Name = "HLC Avg";
    HLCAvg.DrawStyle = DRAWSTYLE_IGNORE;

    HLAvg.Name = "HL Avg";
    HLAvg.DrawStyle = DRAWSTYLE_IGNORE;

    /*  BidVol.Name = "Bid Vol";
    BidVol.DrawStyle = DRAWSTYLE_IGNORE;

    AskVol.Name = "Ask Vol";
    AskVol.DrawStyle = DRAWSTYLE_IGNORE;*/

    GraphDisplacement.Name = "Diplacement Amount";
    GraphDisplacement.SetDescription("The amount to add to the base graph values. This can be positive or negative.");
    GraphDisplacement.SetFloat(0.0f);
    GraphDisplacement.SetFloatLimits(-10000.0f, 10000.0f);

    return;
  }

  // If our start index is zero, then we want to clear our existing chart
  // data, if any, so we start clean to avoid any possible problems. This
  // is accomplished by using sc.ResizeArrays.
  if (sc.UpdateStartIndex == 0)
  {
    sc.ResizeArrays(0);
  }

  // Do data processing
  for (int i = sc.UpdateStartIndex; i < sc.ArraySize; i++)
  {
    if (sc.OutArraySize - 1 < i)
      sc.AddElements(1);

    sc.DateTimeOut[i] = sc.BaseDateTimeIn[i];

    for (int SubGraph = 0; SubGraph <= 8; SubGraph++)
    {
      if (SubGraph >= 0 && SubGraph <= 3)
        sc.Subgraph[SubGraph][i] = sc.BaseDataIn[SubGraph][i] + GraphDisplacement.GetFloat();
      else
        sc.Subgraph[SubGraph][i] = sc.BaseDataIn[SubGraph][i];

      //For testing coloring bars
      //sc.Subgraph[SubGraph].DataColor[i] = RGB(255,255,255);
    }
  }
}