Login Page - Create Account

Support Board


Date/Time: Thu, 28 Nov 2024 13:39:36 +0000



Post From: ACSIL chart color functions

[2023-04-29 15:10:21]
Sierra_Chart Engineering - Posts: 17201
SCSFExport scsf_GraphicsSettingsExample(SCStudyInterfaceRef sc)
{
  SCSubgraphRef Subgraph_SimpleMA = sc.Subgraph[0];

  // Set configuration variables

  if (sc.SetDefaults)
  {
    // Set defaults

    sc.GraphName = "Chart Graphics Settings Example";

    sc.StudyDescription =
"This example will change the color of the chart background, when the price is above a simple moving average. Add this study during a chart replay for a demonstration.";

    sc.GraphRegion = 0;

    Subgraph_SimpleMA.Name = "Simple Moving Average";
    Subgraph_SimpleMA.DrawStyle = DRAWSTYLE_LINE;
    Subgraph_SimpleMA.PrimaryColor = RGB(0, 255, 0);

    sc.AutoLoop = 0;

    return;
  }


  // Do data processing
  if (sc.IsFullRecalculation)
  {
    //Specify to use the chart graphic settings.
    sc.SetUseGlobalGraphicsSettings(sc.ChartNumber, false);
  }

  uint32_t Color = 0;
  uint32_t LineWidth = 0;
  SubgraphLineStyles LineStyle = LINESTYLE_UNSET;

  for (int BarIndex = sc.UpdateStartIndex; BarIndex < sc.ArraySize; BarIndex++)
  {
    // Simple moving average in the first subgraph
    sc.SimpleMovAvg(sc.Close, Subgraph_SimpleMA, BarIndex, 10);

    sc.GetGraphicsSetting(sc.ChartNumber, n_ACSIL::GRAPHICS_SETTING_CHART_BACKGROUND, Color, LineWidth, LineStyle);

    if (Subgraph_SimpleMA.Data[BarIndex] < sc.Close[BarIndex])
    {
      if (Color != RGB(255, 0, 0))
      {
        Color = RGB(255, 0, 0);
        sc.SetGraphicsSetting(sc.ChartNumber, n_ACSIL::GRAPHICS_SETTING_CHART_BACKGROUND, Color);
      }

    }
    else
    {
      if (Color != RGB(0, 0, 0))
      {
        Color = RGB(0, 0, 0);
        sc.SetGraphicsSetting(sc.ChartNumber, n_ACSIL::GRAPHICS_SETTING_CHART_BACKGROUND, Color);
      }
    }
  }


}

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: 2023-04-29 15:11:00