Login Page - Create Account

Support Board


Date/Time: Sun, 24 Nov 2024 14:08:35 +0000



Post From: code help

[2024-06-02 11:32:46]
User431178 - Posts: 541
Suggest looking at the examples that can be found in the ACS_Source folder of your Sierra Chart installation.
Once you've done that you should have a better idea of how to structure the study.

Information here: How to Build an Advanced Custom Study from Source Code: Searching for Source Code for Sierra Chart Built-In Studies

An example of what you can expect to find is shown below, there are 100's of examples in the various files.


/*============================================================================
  This study displays the simple, exponential, and adaptive moving
  averages.
----------------------------------------------------------------------------*/
SCSFExport scsf_MovingAverageExample1(SCStudyInterfaceRef sc)
{
  SCSubgraphRef Subgraph_SimpleMA = sc.Subgraph[0];
  SCSubgraphRef Subgraph_ExponentialMA = sc.Subgraph[1];
  SCSubgraphRef Subgraph_AdaptiveMA = sc.Subgraph[2];

  // Set configuration variables
  
  if (sc.SetDefaults)
  {
    // Set defaults
    
    sc.GraphName = "Moving Average Example 1";
    
    sc.StudyDescription = "";
    
    sc.GraphRegion = 0;
    
    Subgraph_SimpleMA.Name = "Simple Moving Average";
    Subgraph_SimpleMA.DrawStyle = DRAWSTYLE_LINE;
    Subgraph_SimpleMA.PrimaryColor = RGB(0,255,0);
    
    Subgraph_ExponentialMA.Name = "Exponential Moving Average";
    Subgraph_ExponentialMA.DrawStyle = DRAWSTYLE_LINE;
    Subgraph_ExponentialMA.PrimaryColor = RGB(255,0,255);
    
    Subgraph_AdaptiveMA.Name = "Adaptive Moving Average";
    Subgraph_AdaptiveMA.DrawStyle = DRAWSTYLE_LINE;
    Subgraph_AdaptiveMA.PrimaryColor = RGB(255,255,0);

    sc.AutoLoop = 1;

    return;
  }
  
  
  // Do data processing
  
  
  // Simple moving average in the first subgraph
  sc.SimpleMovAvg(sc.Close, Subgraph_SimpleMA, 10);
  
  // Exponential moving average in the second subgraph
  sc.ExponentialMovAvg(sc.Close, Subgraph_ExponentialMA, 10);
  
  // Adaptive moving average in the third subgraph
  sc.AdaptiveMovAvg(sc.Close, Subgraph_AdaptiveMA, 10, 2.0f, 30.0f);
}