Login Page - Create Account

Support Board


Date/Time: Thu, 25 Apr 2024 11:57:41 +0000



Using Subgraph.DataColor to change background color in ACSIL

View Count: 718

[2022-10-01 07:28:51]
User29662 - Posts: 76
Sierra Chart Documentation states that:

"An ACSIL (Advanced Custom Study Interface and Language) study can optionally use the sc.Subgraph[].DataColor array to use alternate coloring for the background at each chart column that differs from the primary color."

Are there any examples out there of how this would be coded?
[2022-10-02 18:00:09]
Ackin - Posts: 1865
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));
  }
}

[2022-10-02 18:43:15]
Sierra_Chart Engineering - Posts: 14076
This would only work, if you set the Draw Style for that Subgraph to Background as is given in the example in the prior post.:
Subgraph_Background.DrawStyle = DRAWSTYLE_BACKGROUND;



More information:
ACSIL Interface Members - sc.Subgraph Array: sc.Subgraph[].DrawStyle
Sierra Chart Support - Engineering Level

Your definitive source for support. Other responses are from users. Try to keep your questions brief and to the point. Be aware of support policy:
https://www.sierrachart.com/index.php?l=PostingInformation.php#GeneralInformation

For the most reliable, advanced, and zero cost futures order routing, use the Teton service:
Sierra Chart Teton Futures Order Routing
Date Time Of Last Edit: 2022-10-02 18:43:25

To post a message in this thread, you need to log in with your Sierra Chart account:

Login

Login Page - Create Account