TradingView Volatility Targeting Tools Cheat Sheet

Here’s a simple guide to using RW’s TradingView Volatility Targeting Tools. Watch the video or read the instructions below.

The links to get the tools are in the first paragraph below.

What are the volatility targeting tools?

A suite of TradingView scripts for calculating and exploring position sizing using the volatility targeting approach.

The tools consist of:

  • The VolTargeting library: contains functions for estimating volatility and calculating positions sizes.
  • The Vol-Targeted Position Size indicator: plots the volatility-targeted position size over time, as well as the no-trade region. Information for the most recent price data is output in a table.
  • The Vol-Targeted Position Size strategy: a TradingView strategy that rebalances a position back to a volatility target when the current position falls outside the no-trade region.

What is volatility targeting?

A position sizing technique where you attempt to size your position such that it delivers a specified amount of volatility to your portfolio.

Volatility is known to be somewhat sticky or autocorrelated. Therefore, we use an estimate of realised volatility (derived from an exponentially weighted variance) for our forecast of future volatility.

For example, say we have a portfolio worth $100,000. We want SPY to deliver 10% volatility to our portfolio. So we go and estimate SPY’s current volatility, which comes out at 21% annualised (say). We use this as our forecast of future volatility.

Let’s also say that SPY is trading at $500.

If we were fully invested in SPY, our position in shares would be $100,000/$500 = 200. However, this would deliver us the full 21% volatility of SPY.

So we need to scale our position size by the ratio of the volatility we want to the volatility we forecast for SPY:

pos = $100,000/$500 * 10/21 = 95

So our 10%-volatility-targeted position size would be 95 shares.

What is the no-trade region?

As the market moves and the volatility of SPY changes, so will the target position that you need for your 10% volatility target.

So in order to hit your volatility target, you would need to regularly rebalance your position back to the target size.

However, trading is expensive. And we would like to do the minimum amount required.

So rather than hyperactively rebalancing to every little change, we introduce the concept of a no-trade region around our target position. We rebalance back to the target position only when our existing position falls outside of the no-trade region.

This is one way to navigate the trade-off between realising your volatility target and minimising the costs of doing so.

The smaller you define your no-trade region, the more tightly your position will conform to the target position, but the higher your trading costs.

Finding a sensible value for the no-trade region is usually found by simulation. You can use the Vol-Targeted Position Size strategy in TradingView to run such simulations and explore the trade-offs.

We have an article on the no-trade region on the RW blog here.

How to use the tools?

Using the library

You would use the VolTargeting library if you wanted to write your own indicators or strategies using the same functions we used.

Use the library by importing it directly into a pine script:

import robotkris/VolTargeting/2 as VolTargeting

Usage examples and source code can be found with the library on TradingView here.

Using the indicator

To use the indicator, you need to:

  • Add it to your favourite indicators
  • Add it to a chart
  • Set the input parameters

Add the indicator to your favourites

Go to the indicator’s TradingView page:

indicator page image

Scroll down to the box with the blue outline and the title "Open-source script" and click the button that says "Add to favourite indicators":

os script box

Add the indicator to a chart

Now open up a chart and click "Indicators". The Vol-Targeted Position Size indicator will appear in your favourites. Click it to add it to the chartL

Indicator add to chart

Set the input parameters

Now set the input parameters. Hover over the indicator’s title in the lower plot window and click the hexagon. This will open up the inputs dialogue box with the default values. Change these as necessary.

Input parameters

The inputs are:

  • Balance: the portfolio value
  • Volatility estimation window length: the half-life of the exponentially weighted volatility estimate. Lower values will put more weight on recent history.
  • Target volatility contribution: how much volatility you want this asset to deliver to your portfolio as a percentage.
  • Size of no-trade region as % of target position size: For example, the default value of 5% gives a no-trade region of targetPos – noTradeRegion*targetPos : targetPos + noTradeRegion*targetPos (that is, target position +/- 5%)

Indicator outputs

The indicator outputs a plot and some tabulular data in a window below the price chart:

plot

  • The orange region is a time-series of the no-trade region
  • The blue line is a time-series of the vol-targeted position size
  • The green box shows information related to the last bar in the price chart – you could use this to size a position at the current price and volatility forecast.

Important point: the indicator doesn’t consider leverage constraints, so do check that your volatility target doesn’t result in a position that exceeds your available leverage.

Using the strategy

The strategy applies the Vol-Targeted Position Size indicator as a TradingView strategy. It rebalances a position back to the target position with consideration to the no-trade region.

Use it explore the tradeoffs that come with changing the no-trade region parameter: larger values will result in less trading (and less cost) but lower fidelity to the target position.

As with indicator, to use the strategy, you need to add it to your favourites and then add it a chart and set the input parameters. You can then use the Strategy Tester feature of TradingView to explore the strategy.

Add the strategy to your favourites

Go to the strategy’s TradingView page:

strategy page image

Scroll down to the box with the blue outline and the title "Open-source script" and click the button that says "Add to favourite indicators":

strategy os script box

Add the strategy to a chart

Now open up a chart and click "Indicators". The Vol-Targeted Position Size strategy will appear in your favourites. Click it to add it to the chart:

strategy add to chart

Set the input parameters

The strategy uses the same inputs as the indicator, except for the balance parameter:

  • Volatility estimation window length: the half-life of the exponentially weighted volatility estimate. Lower values will put more weight on recent history.
  • Target volatility contribution: how much volatility you want this asset to deliver to your portfolio as a percentage.
  • Size of no-trade region as % of target position size: For example, the default value of 5% gives a no-trade region of targetPos – noTradeRegion*targetPos : targetPos + noTradeRegion*targetPos (that is, target position +/- 5%)

strategy inputs

Instead of a user-specified balance, the strategy takes its initial capital value from the Properties dialogue box. Set it by clicking "Properties" and changing the value in the "Initial capital" field:

Initial strategy capital

You can also add costs in the Properties dialogue box – this will help you explore the trade off between rebalancing fidelity and the cost of trading.

Strategy outputs

The strategy outputs the same plot as the indicator, except it also adds a green line for your current position and shows rebalance trades in the price window:

strategy plot

You can see the strategy rebalancing the current position whenever it falls outside the no-trade region.

Using the Strategy Tester

Click the "Strategy Tester" tab below the chart.

The Strategy Tester consists of four tabs:

  • Overview: shows an equity curve of the strategy overlaid with the buy and hold equity curve
  • Performance summary: shows a table of performance metrics – most of which are actually quite useless
  • List of trades: unfortunately also quite useless – TradingView uses a framework based on "entries and exits" rather than positions/exposures.
  • Properties: summary of the strategy’s inputs, properties and metadata

To be frank, the most useful thing about the strategy tester is being able to eyeball the strategy’s equity curve versus the buy and hold equity curve. In the case of our Vol-Targeting strategy, we hope to see a smoother ride than the buy and hold case:

As expected, our strategy does deliver a smoother ride, which makes sense given that we’ve targeted less volatility than delivered by 100% exposure to the asset.

In the Performance Summary tab, the only things I’d look at are the Sharpe Ratio and the Commissions Paid figures. The Sharpe Ratio represents a raw monthly Sharpe, so to annualise it you’d need to multiply it by sqrt(12). The rest of the figures mostly relate to "trade statistics" which are pretty meaningless (generally, and in particular in the context of rebalancing to a target exposure).