StDevAll

StDevAll ( double extendToRight , IDataHolder data , int length , int startDate , int startTime , double extendToLeft , double extendToRight );

Default values:

extendToRight: No length: all chart startDate: 0 startTime: 0 extendToLeft: No extendToRight: No

Description

Returns the standard deviation of data for the entire plot or for the interval of the last bars defined by the length parameter. The difference of this function from StDev is that the output result for the last bar is used for the whole interval calculated.

If the length parameter is not specified, the function is calculated for the entire plot.

The startDate (specified in the YYYYMMDD format) and startTime (specified in the HHMM format) define the date and time for the starting point of linear regression. These parameters override any value of the length if startDate is non-zero.

By default, the function will return Double.NaN at any moment in time outside the interval used for calculation of linear regression. This behavior can be changed by using non-zero values of extendToLeft and extendToRight parameters.

Input parameters

Parameter Default value Description
data - Defines the variable for which the standard deviation is calculated.
length all chart If specified, defines number of the last bars for which the curve is plotted, otherwise, the curve is plotted for the whole chart.
startDate 0 If specified, defines the date of starting point for calculation of standard deviation, in the YYYYMMDD format.
startTime 0 If specified, defines the time of starting point for calculation of standard deviation, in the YYYYMMDD format.
extendToLeft No Defines whether or not to extend the standard deviation curve to the left of the end point.
extendToRight No Defines whether or not to extend the standard deviation curve to the right of the end point.

Example

input price = close;

def regression = InertiaAll(price, 30);
def stdDeviation = StDevAll(price, 30);

plot UpperLine = regression + stdDeviation;
plot LowerLine = regression - stdDeviation;

The example draws the Standard Deviation Channel, which is the linear regression channel spaced by standard deviation. The deviation channel is based on price data for the last 30 bars.