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
- High values indicate that intraday prices have a wide high to low range. Low values indicate that intraday prices have relatively constant high to low range.
- 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.
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 = vlty[bar];
n = Math.Round( v ) % 10;
if( ( n < 0 ) || ( n > 9 ) ) n = 0;
SetBarColor( bar, WS4ColorToNET( n * 100 ) );
}
}
}
}