SemiStandardDev (Function)
The SemiStandardDev function calculates a standard deviation of values (based either on the population or a sample) above the mean or a standard deviation of values below the mean. See below for more information.
Syntax
SemiStandardDev(Price, Length, PopOrSample, DownsideOrUpside);
Returns (Double)
A numeric value containing the Semi Standard Deviation.
Parameters
Name |
Type |
Description |
Price |
Numeric |
EasyLanguage expression (price, function, formula, etc.) used as the price in the standard deviation calculations. |
Length |
Numeric |
The number of bars over which to calculate the standard deviation. |
PopOrSample |
Numeric |
Pass in 1 for the entire population, or pass in 2 for a sample. |
DownsideOrUpside |
Numeric |
Pass in 1 to calculate downside standard deviation; pass in 2 to calculate upside standard deviation. |
Remarks
This function returns the standard deviation of data points that are below the mean (if 1 is passed in for the “DownsideOrUpside” input) or the standard deviation 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
Assigns to Value1 the sample type standard deviation of the Close over 21 bars for downside standard deviation (data points below the mean):
Value1 = SemiStandardDev(Close , 21, 2, 1);
Assigns to Value2 the entire population type standard deviation of the High over 21 bars for upside standard deviation (data points above the mean):
Value2 = SemiStandardDev(High , 21, 1, 2);