API ChartStyles Community Components Community Indicators IndexDefinitions Knowledge Base Misc Optimizers PosSizers Providers Standard Indicators TASC Traders Tips TASCIndicators Visualizers |

**Main Page**- Category List
- Knowledge Base
- Tutorial Videos
- Traders Tips
- Indicator documentation
- Addin examples

Advanced Search »

```
public static StdDev Series(DataSeries ds, int period, WealthLab.Indicators.StdDevCalculation calcType)
public StdDev(DataSeries ds, int period, StdDevCalculation calcType, string description)
public static double Value(int bar, DataSeries ds, int period, StdDevCalculation calcType)
```

ds |
The source DataSeries |

period |
Indicator calculation period |

calcType |
WealthLab.Indicators.StdDevCalculation public const WealthLab.Indicators.StdDevCalculation Population = 0 public const WealthLab.Indicators.StdDevCalculation Sample = 1 |

- Standard deviation rises as prices become more volatile. As price action calms, standard deviation heads lower.
- Market tops accompanied by increase volatility over short periods of time, indicate nervous and indecisive traders. Or market tops with decreasing volatility over long time frames, indicate maturing bull markets.
- Market bottoms accompanied by decreased volatility over long periods of time, indicate bored and disinterested traders. Or market bottoms with increasing volatility over relatively sort time periods, indicate panic sell off.

- Avoid testing StdDev of a Standard Price Series (Bars.Open, Bars.Close, etc.) for an absolute value since these series can be adjusted (split) in the future, which will change their historic deviations. Instead, normalize the test by dividing both StdDev and the value (or series) by the DataSeries value.

`if( StdDev.Value( bar, Close, 20 ) < 1.5 ...`

```
/* Normalized */
double C = Close[bar];
if( ( StdDev.Series( Close, 20 )[bar] / C ) < ( 1.5 / C ) )...
```

Steps to calculate Standard Deviation for n periods

- Calculate the mean price by summating the price for n periods and divide by n.
- From each period's price subtract the mean, this gives you the deviation for each period.
- Find the sum of the squares of all deviations.
- Divide the sum of the squared deviations found in step 3 by ( n - 1 ).
- Calculate the square root of the result of the previous step.

```
using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing;
using WealthLab;
using WealthLab.Indicators;
```

namespace WealthLab.Strategies
{
public class MyStrategy : WealthScript
{
protected override void Execute()
{
// Divide Standard Deviation by Average Price to arrive at a normalized Volatility indicator
DataSeries MyVolatility = StdDev.Series( Close, 30, StdDevCalculation.Population ) / SMA.Series( Close, 30 );
MyVolatility.Description = "Normalized Volatility";
ChartPane VolPane = CreatePane( 50, true, true );
PlotSeries( VolPane, MyVolatility, Color.Purple, LineStyle.Histogram, 3 );
// Plot Std Dev Bands aka Bollinger Bands
HideVolume();
DataSeries StdDevBand = StdDev.Series( Close, 20, StdDevCalculation.Population ) * 2;
DataSeries StdH = SMA.Series( Close, 20 ) + StdDevBand;
DataSeries StdL = SMA.Series( Close, 20 ) - StdDevBand;
PlotSeriesDualFillBand( PricePane, StdH, StdL, Color.FromArgb(10,10,0,0), Color.Empty, Color.Empty, LineStyle.Solid, 1 );
}
}
}