Volatility

Modified on 2008/05/03 16:24 by Administrator — Categorized as: Standard Indicators

Syntax

public static Volatility Series(Bars bars, int emaPeriod, int rocPeriod) public Volatility(Bars bars, int emaPeriod, int rocPeriod, string description)

Parameter Description

bars The Bars object
emaPeriod EMA period
rocPeriod ROC period

Description

Return's Chaikin's Volatility indicator of the EMA and ROC periods. Chaikin's Volatility first calculates an EMA of the difference between the High and Low price. The Volatility indicator is then created by taking the ROC of this value over a period specified by rocPeriod. The period of the EMA is specified in the period parameter.

Interpretation


Calculation

First calculate an EMA of the difference between High and Low price.

HLAve = 10-day EMA( High - Low)


Then take the ROC of this value over a period specified by rocPeriod.

CV = ( HLAve) / ( HLAve n days ago)

where,
CV = Chaikin's Volatility value
n = number of ROC periods

Example

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

namespace WealthLab.Strategies { public class MyStrategy : WealthScript { // Thank you fundtimer public Color WS4ColorToNET( double WS4Color ) { return Color.FromArgb( (int)Math.Floor( ( WS4Color % 1000 ) / 100 * 28.4 ), (int)Math.Floor( ( WS4Color % 100 ) / 10 * 28.4 ), (int)Math.Floor( WS4Color % 10 * 28.4 ) ); } protected override void Execute() { // Colors bars with higher intensity red as volatility increases DataSeries vlty = Volatility.Series( Bars, 14, 10 ); double v = 0; double n = 0; ChartPane VolPane = CreatePane( 50, true, true ); PlotSeries( VolPane, vlty, Color.DarkBlue, LineStyle.Solid, 2 ); SetBarColors( Color.Silver, Color.Silver );

// Volatility is an unstable indicator for(int bar = 45; bar < Bars.Count; bar++) { v = vltybar; n = Math.Round( v ) % 10; if( ( n < 0 ) || ( n > 9 ) ) n = 0; SetBarColor( bar, WS4ColorToNET( n * 100 ) ); } } } }