Click or drag to resize

Constructors

Technical indicators typically have the following types of constructors:

As an example, suppose we want to use a Simple Moving Average (Sma) indicator.  It has the following constructors:

Sma – sets default values, for Sma the default value is 14.

Sma(Int32) – sets values for period

Sma(TimeSpan) – sets time period.  This constructor is used in case you want to calculate the indicator value by time period.  For instance, you can use it to calculate simple moving average of one hour.

The following expression creates a new instance. In this case period of this indicator will be set by default; for SMA default is 14:

C#
1Sma sma = new Sma();

 In the case below we set period 28 for Sma:

C#
1Sma sma = new Sma(28);

 In the next case, indicator values will be calculated as average of all values during the last minute:

C#
1Sma sma = new Sma(new TimeSpan(0,1,0));