Login Page - Create Account

Support Board


Date/Time: Fri, 19 Apr 2024 16:04:30 +0000



Post From: Using Subgraph.DataColor to change background color in ACSIL

[2022-10-02 18:00:09]
Ackin - Posts: 1863
Are there any examples out there of how this would be coded?

...\SierraChart\ACS_Source\studies8.cpp



SCSFExport scsf_BackgroundDrawStyleExample(SCStudyInterfaceRef sc)
{
  SCSubgraphRef Subgraph_Background = sc.Subgraph[0];
  SCSubgraphRef Subgraph_BackgroundDC = sc.Subgraph[1];

  if (sc.SetDefaults)
  {
    // Set the configuration and defaults
    sc.GraphName = "Background DrawStyle Example";
    sc.StudyDescription = "Background DrawStyle Example";

    sc.AutoLoop = true;
    

    sc.GraphRegion = 0;
    sc.DrawStudyUnderneathMainPriceGraph = 1; // not required in studies, but want color behind price for this study

    Subgraph_Background.Name = "Background";
    Subgraph_Background.DrawStyle = DRAWSTYLE_BACKGROUND;
    Subgraph_Background.PrimaryColor = COLOR_LIGHTGREEN;
    Subgraph_Background.SecondaryColor = COLOR_LIGHTPINK;
    Subgraph_Background.SecondaryColorUsed = true; // turn on if both colors are to be used
    Subgraph_Background.AutoColoring = AUTOCOLOR_POSNEG; // use positive/negative values to signify colors

    Subgraph_BackgroundDC.Name = "Background DataColor";
    Subgraph_BackgroundDC.DrawStyle = DRAWSTYLE_BACKGROUND;
    Subgraph_BackgroundDC.PrimaryColor = RGB(255,0,255);

    return;
  }

  // Do data processing
  int min = sc.BaseDateTimeIn[sc.Index].GetMinute();

  if (min > 0 && min < 15)
    Subgraph_Background[sc.Index] = 0; // do not color background
  else if (min >= 15 && min < 30)
    Subgraph_Background[sc.Index] = 1; // use primary color
  else if (min >= 30 && min < 45)
    Subgraph_Background[sc.Index] = -1; // use secondary color
  else if (min >= 45 && min < 60)
  {
    Subgraph_BackgroundDC[sc.Index] = 1;
    Subgraph_BackgroundDC.DataColor[sc.Index] = RGB(0, 0, 17*(60-min));
  }
}