Привет всем,
Предлагаю для тестирования индикатор Chaikin's Volatility. Его описание взято с сайта Wealth-Lab.

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

Calculation
http://www.incrediblecharts.com/indicators/chaikin_volatility.php

To calculate Chaikin Volatility:
First, calculate an exponential moving average (normally 10 days) of the difference between High and Low for each period:
EMA [H-L]
Next, calculate the percentage change in the moving average over a further period (normally 10 days):
( EMA [H-L] - EMA [H-L 10 days ago] ) / EMA [ H-L 10 days ago] * 100

Код индикатора следующий:

using System.Collections.Generic;
using System.Linq;
using TSLab.Script;
using TSLab.Script.Handlers;
using TSLab.Script.Helpers;


namespace TSLab.Community.Volatility
{
//[HandlerCategory("Indicators")]
public class Volatility : IBar2DoubleHandler
{
[HandlerParameter]
public int EMAPeriod { get; set; }

[HandlerParameter]
public int ROCPeriod { get; set; }

public IList<double> Execute(ISecurity source)
{
var highPrices = source.HighPrices;
var lowPrices = source.LowPrices;
var hlDiff = new List<double>(highPrices.Count);
for (int i = 0; i < highPrices.Count; i++)
{
hlDiff.Add(highPrices[i] - lowPrices[i]);
}

var emaDiff = Series.EMA(hlDiff, EMAPeriod);

var volatility = new double[highPrices.Count];
for (int i = highPrices.Count - 1; i >= ROCPeriod; i--)
{
volatility[i] = (emaDiff[i] - emaDiff[i - ROCPeriod]) / emaDiff[i - ROCPeriod] * 100;
}

return volatility.ToList();
}
}

}


Также прикладываю .dll, которую надо положить в директорию TsLab\ Handlers\, и тогда индикатор Volatility появится во вкладке Пользовательских индикаторов.
Просьба критиковать и высказывать замечания.

Спасибо


Attachments
TSLab.Community.Volatility.zip (323 downloads)
TSLab.Community.zip (282 downloads)