SemiVariancePS (Function)

image\trumpet2.gif Disclaimer

The SemiVariancePS function calculates the estimated variance of values above the mean or values below the mean based either on the population or a sample. See below for more information.

Syntax

SemiVariancePS(Price, Length, PopOrSample, DownsideOrUpside);

Returns (Double)

A numeric value containing the estimated semi-variance for a set of values over length bars.

Parameters

Name

Type

Description

Price

Numeric

EasyLanguage expression (price, function, formula, etc.) used as the price in the semi-variance calculations.

Length

Numeric

The number of bars over which to calculate the semi-variance.

PopOrSample

Numeric

Pass in 1 for the entire population, or pass in 2 for a sample.

DownsideOrUpside

Numeric

Pass in 1 to calculate downside semi-variance; pass in 2 to calculate upside semi-variance.   

Remarks

Variance is the measure of the "scatter" of prices around the mean of a sample. This function returns the variance of data points that are below the mean (if 1 is passed in for the “DownsideOrUpside” input) or the variance of data points that are above the mean (if 2 is passed in for the “DownsideOrUpside” input). The values from this function are sometimes used as a measurement of downside risk (for a long position) or upside risk (for a short position).

Example

Downside variance of the Close for a sample over 14 bars:

Value1 = SemiVariancePS(Close, 14, 2, 1);

Upside variance of the High for an entire population for 21 bars:

Value2 = SemiVariancePS(High, 21, 1, 2);