Percent volatility
How the percent volatility gives the average absolute percent change between consecutive prices over a block of N changes, and how to use it in a QTSurfer strategy.
The percent volatility is the average size of the changes of the price, as a percentage: how much it moves from one update to the next, on average. Being a percentage, it can be compared between instruments.
Try it on a series below and change the period.
The series are samples, synthetic ones and real crypto ones. They show how the indicator behaves, not what it earns. The line is computed in your browser by the engine’s own indicator class, so it is the line a strategy reads.
What it computes
change = 100 × |price − previous price| / previous price
percent volatility = the mean of `change` over a block of N changes The engine feeds each change into a simple average, and its default one is the discrete one of the SMA page: the value is the mean of the last complete block of N changes, renewed once per block, so the line is a staircase that steps every N updates. It is ready after N changes, which is the update number N + 1.
Reading it
- It is per update, so it depends on the timeframe: the change from one hour to the next is not that from one day to the next.
- It is a percentage, unlike the ATR and the standard deviation, which are in the units of the price, so it compares instruments directly.
- It counts the size of each change, not its direction: a rise and a fall of the same size weigh the same.
In a strategy
setup:
percentVolatility(5) percentVolatility(5) registers pvol5. In Java, .percentVolatility(5) on the builder.
The period is a parameter, so a parameter sweep can explore it, and walk-forward analysis tells you whether what it found holds outside the sample, which is the defence against overfitting.
Related
- ATR: the range of a bar, in the units of the price.
- Standard deviation: the spread of the prices, in the units of the price.
- Volatility: how often the price changes.
- QTScript indicators and Java indicators: every indicator a strategy can call, with its forms and the names it registers.