Login Page - Create Account

Support Board


Date/Time: Mon, 23 Dec 2024 15:35:34 +0000



Post From: Line On Line by Code

[2015-10-02 13:03:05]
mkata - Posts: 103
KhaosTrader,
There were only two mistakes.
1) Average_Inner = sc.Subgraph[0] needed its own #
2) Each Subgraph needs to have a .Name to appear in Study Settings window (ex. Average_Inner.Name = "Average")

I went ahead and made the changes.



SCSFExport scsf_SimpMovAvg(SCStudyInterfaceRef sc)

{
SCSubgraphRef Average_Outter = sc.Subgraph[0];
SCSubgraphRef Average_Inner = sc.Subgraph[1];

SCInputRef Length = sc.Input[0];

// Set configuration variables
if (sc.SetDefaults)
{
// Set the configuration and defaults
sc.GraphName = "SimpleX Moving Average";
sc.StudyDescription = "Example function for calculating a simple moving average.";
sc.GraphRegion = 0;
sc.AutoLoop = 1;
sc.AlertOnlyOncePerBar = true;
  sc.FreeDLL = 1;


// Set the color, style and line width for the subgraph
Average_Outter.Name = "Average_Outter";
  Average_Outter.PrimaryColor = RGB(112,0,0);
  Average_Outter.DrawStyle = DRAWSTYLE_LINE;
  Average_Outter.LineStyle = LINESTYLE_SOLID;
  Average_Outter.LineWidth = 6;

  Average_Inner.Name = "Average_Inner";
  Average_Inner.PrimaryColor = RGB(255,255,255);
  Average_Inner.DrawStyle = DRAWSTYLE_LINE;
  Average_Inner.LineStyle = LINESTYLE_DASHDOT;
  Average_Inner.LineWidth = 1;

// Set the Length input
Length.Name = "Length";
  Length.SetInt(20);
  Length.SetIntLimits(1,MAX_STUDY_LENGTH);
  Length.SetDescription("The number of bars to average.");

return;

}
// Do data processing
// Calculate a simple moving average from the base data

sc.SimpleMovAvg(sc.Close,Average_Outter,Length.GetInt());
sc.SimpleMovAvg(sc.Close,Average_Inner,Length.GetInt());

}

Date Time Of Last Edit: 2015-10-02 13:03:34