Shows historic volatility as you pass the period to it.
NOTE: This is only usable while in a minute or smaller timeframe. It collects the number based on a cumulation of intersession closes. So the period you pass to it is the number of sessions. For a more flexible volatility tool look to my HistVolAny function posted around the same time as this. Note however that this is the correct tool if you wish to refer only to the same scale of volatility as something like VIX measures (this result correlates to VIX). Useful for an intraday system that you want to control based on broad interday volatility trends.
So HistVol(30)[0] calculates today's historic volatility based on the last 30 days of data. Historic volatility doesn't change during the day in this indicator. It is calculated once at open (since it is based off of previous market closes only). Note you need to open plenty of backfill into your charts to use this.
I programmed this on NT 6.5, so no guarantees for 6.0. Also, any performance issues you have should probably be posted here. I'm new to writing these and have a lot to learn, so maybe progress can be made in discussion.
Finally though, if you have a system that you want to dynamically adjust stops and profits, or just stay out, based on volatility, you now have something to work with.
Also note that I've based this indicator off of subsequent closes, not high versus low of consecutive days. This is all customizable. I matched these results up to CBOT data for some contracts I trade, and it looks good.
This uses natural log and standard deviation to derive historic volatility for a set of data (however long the period). The longer period should perform slower.
Comment