Log in to see Cloud of Tags

Wealth-Lab Wiki

Variance Ratio


VarianceRatio: Indicator Documentation


public VarianceRatio(Bars bars, DataSeries ds, int lookback, int period) public VarianceRatio(Bars bars, DataSeries ds, int lookback, int period, string description)

Parameter Description

bars Bars object
ds The price series to work on
lookback The lookback period
period The averaging period


The Variance Ratio indicator by Dr. Rene Koch (originally developed here) is a measure for the trendiness or degree of mean reversion in a price series.

From "A Small-Sample Overlapping Variance-Ratio Test" by Tse et al:

Since the works of Cochrane (1988) and Lo and MacKinlay (1988, 1989) the variance ratio (VR) statistic has been used widely as a test for the random-walk hypothesis. Campbell and Mankiw (1987a, 1987b, 1989), Cogley (1990) and Poterba and Summers (1988) used the VR statistic to measure the persistence in economic time series. Lo and MacKinlay (1989) demonstrated that the VR test is more powerful than either the Dickey-Fuller test or the Box-Pierce Q test for several interesting alternatives. Cecchetti and Lam (1994) summarized the advantages of using the VR test.


  • If the Variance Ratio is 1, the price series is a pure random walk. No predictions are possible and hence any trial to craete a profitable trading system on such a price series will fail.
  • If the Variance Ratio is larger than 1, the price series shows a tendency to form trends, i.e. changes in one direction are more often followed by changes in the same direction.
  • If the Variance Ratio is below 1, the price series shows some degree of mean reversion. Changes in one direction are more often followed by changes in the opposite direction.


This is a very simplistic implementation of a "rolling" variance ratio test. Any outliers in the price series will bias the results towards smaller values. There is another bias for small samle sizes (small Period). The usual disadvantages of the SMA() which is used internally in the StdDev() function apply.


This strategy is a port of the V4 chartscript RSI + Variance Ratio Filter by slow_learner and tests the impact of using the variance ratio as a filter on a standard RSI system:

using System; using System.Collections.Generic; using System.Text; using System.Drawing; using WealthLab; using WealthLab.Indicators; using Community.Indicators;

namespace WealthLab.Strategies { public class RSI_VarianceRatio_Filter : WealthScript { protected override void Execute() { LineStyle ls = LineStyle.Solid; LineStyle ld = LineStyle.Dotted; Color silver = Color.Silver; VarianceRatio vr = VarianceRatio.Series(Bars, Close, 20, 400); double sensitivity = 0.9; ChartPane vr_p = CreatePane(30, true, false); PlotSeries(vr_p, vr, Color.Blue, ls, 1 ); DrawHorzLine(vr_p, sensitivity, Color.Red, ls, 2 ); RSI rsi_s = RSI.Series(Close, 14); ChartPane RSI_p = CreatePane( 30, true, false ); int RSI_lower = 30; int RSI_upper = 70; PlotSeries( RSI_p, rsi_s, Color.Blue, ls, 1 ); DrawHorzLine(RSI_p, RSI_lower, silver, ld, 2 ); DrawHorzLine(RSI_p, 50, silver, ld, 2 ); DrawHorzLine(RSI_p, RSI_upper, silver, ld, 2 ); for(int bar = 20; bar < Bars.Count; bar++) { if (vrbar > sensitivity) SetBackgroundColor(bar, Color.FromArgb(50,Color.LightGreen)); if( ( ActivePositions.Count > 0 ) & CrossOver(bar, rsi_s, RSI_upper) ) SellAtMarket( bar + 1, Position.AllPositions, "RSI Exit" );

if( CrossOver(bar, rsi_s, RSI_lower) & (vrbar > sensitivity) ) BuyAtMarket( bar + 1, "RSI Entry" ); } } } }

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.

ScrewTurn Wiki. Some of the icons created by FamFamFam.