Syntax
Public Function HistoricalVolatility(chart_ID As Integer, applyTo As ENUM_APPLIED_PRICE, period As Integer, BarHistory As Integer, StandardDev As Integer) As String
Description
Historical volatility is the log-normal standard deviation. The Historical Volatility Index is based on the book by Don Fishback, “Odds: The Key to 90% Winners”.
This formula will output a 30-day historical volatility index between 1 and 0:
Stdev(Log(Close / Close Yesterday), 30) * Sqrt(365)
Note that some traders use 252 instead of 365 for the bar history that is used in the square root calculation.
The Log value is a natural log (ie Log10).
Parameters
Key | Description |
chart_ID | Chart identifier, 0 is the current chart ,value of type Long |
applyTo | Applied price , value can be one of the ENUM_APPLIED_PRICE. |
period | The calculation period, on which the indicator will be calculated, value of type Integer. |
BarHistory | History bar count , value of type Integer. |
StandardDev | Standard deviation value of type Integer. |
Return value
Returns the handles of a technical indicator, in case of failure returns an empty string.
Sample
Public Sub main()AlertMessage (HistoricalVolatility(0,price_close,30,365,2))'Draws the indicator on chart and shows a message box with the indicator name.End Sub
See Also