Wealth-Lab Wiki

API ChartStyles Community Components Community Indicators IndexDefinitions Knowledge Base Misc Optimizers Pending Deletion PosSizers Providers Standard Indicators TASC Traders Tips TASCIndicators Tutorial Videos Visualizers
RSS

Navigation


Quick Search
»
Advanced Search »


Syntax

public HV(DataSeries source, int period, int span, string description)
public static HV Series(DataSeries source, int period, int span)

Parameter Description

source Price series
period How many bars HV shall use. The real number of periods that HV will use is Period - 1, because if for example you use 20 price bars, there are 19 periods in between and 19 returns.
span Used to convert the HV to a different time scale. If the Chart has weekly bars and annualized historical volatility is required, use 52 for Span because there are 52 weeks in a year.

Description

Returns the Historical Volatility of the selected Price Series. Historical Volatility is the standard deviation of the logarithm of the price ratio, i.e.

HV = Standard Deviation (ln(Price[bar] / Price[bar-1]))

Interpretation

A sharp increase in HV will alert you to unusual volatility in the markets. This is often an ideal time to monitor the market for entry in the opposite direction of the panic.

Calculation

HV = Sqrt( SSD / ( Period - 1 ) ) * Sqrt( Span )

where,
SSD = Sum( LOGSi - ALOGS ) over Period bars
LOGSi = Logarithm of Price - Previous Price
ALOGS = Sum( Logarithms of Price Change over Span ) / Span

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 { protected override void Execute() { DataSeries Average = (High+Low)/2; DataSeries HV1 = HV.Series( Average, 20, 262 ); HV1.Description = "HV of Average Price"; double stop = 0; double profit = 0;

for(int bar = 262; bar < Bars.Count; bar++) { if (!IsLastPositionActive) { if( HV1[bar] > 100 ) if( ROC.Series( Close, 30 )[bar] > 0 ) ShortAtMarket( bar+1 ); else BuyAtMarket( bar+1 ); } else { Position p = LastPosition; stop = (p.PositionType == PositionType.Long) ? p.EntryPrice * 0.6 : profit = p.EntryPrice * 1.4; profit = (p.PositionType == PositionType.Long) ? p.EntryPrice * 1.15 : profit = p.EntryPrice * 0.85; if( !ExitAtStop( bar, p, stop ) ) ExitAtLimit( bar, p, profit ); } } ChartPane HVPane = CreatePane( 35, true, true ); PlotSeries( HVPane, HV1, Color.Teal, WealthLab.LineStyle.Solid, 2); } } }

Important Disclaimer: The information provided by Wealth-Lab is strictly for informational purposes and is not to be construed as advice or solicitation to buy or sell any security.  The owner of Wealth-Lab.com assumes no liability resulting from the use of the material contained herein for investment purposes. By using this web site, you agree to the terms of this disclaimer and our Terms of Use.

Used under license from FMR Corp. Copyright 2008 FMR Corp. All rights reserved.


ScrewTurn Wiki. Some of the icons created by FamFamFam.