Source codes

This section of the site dedicated to the C++ source codes, which can be useful during developing SierraChart studies. It will be updated during my future work. Let me start this section from the very first must-have file GUI.H. With the help of this file we can write short and clear source codes. Take a look on Days dividers - everything clear even without comments.

Input parameters

If you need to pass some values from user to your study, you must use so called Inputs. At firs you declare Input variable(s):

SCInputRef DebugNumber = sc.Input[0];

Then - set up it parameters:

DebugNumber.Name = "Debug number"; // Text to show as prompt in parameters window
DebugNumber.SetInt(1); // initial value
DebugNumber.SetIntLimits(1,2); // alloved boundaries for value

This must be done only one time - in section if (sc.SetDefaults).

And at last you can get Input value in your study code:

num = DebugNumber.IntValue;

If you have more then one parameter, you can set their displaying order in input window by setting order value(s):

DebugNumber2.DisplayOrder = 2;
DebugNumber3.DisplayOrder = 1;
DebugNumber1.DisplayOrder = 3;

Values specially mixed, to show that order in code and order in input window may be different.

Plotting chart

In order to plot some chart over main prices chart or in separate 'window' you must at first declare it. For example:

SCSubgraphRef PriceLine = sc.Subgraph[0];
  • PriceLine - chart variable name. It's allow you to set up chart parameters and modify its data.
  • 0 - it's an index of this chart

Below is sample code showing the very basic Subgraph usage:

PriceLine.Name = "PriceLine";
PriceLine.ShortName = "[PriceLine]";
PriceLine.DrawStyle = DRAWSTYLE_LINE;
PriceLine.PrimaryColor = RGB(0, 0, 200);
PriceLine.DrawZeros = false;
PriceLine.LineWidth = 2;

// set chart value for current Bar
PriceLine[Bar] = (sc.High[Bar] + sc.Low[Bar]) / 2.0;
 
Copyright © 2014 AlgoTrading.Solutions