Log in to see Cloud of Tags

Wealth-Lab Wiki

TASC 2010-04 | Volume-Price Trend Indictor (Hawkins)

RSS

Traders' Tip text

Overlaying MVPT properly in the PricePane is a big challenge if one must manually adjust both the level and scaling factors. Changing the scale affects the level and vice-versa. For this reason, our Wealth-Lab script creates the MVPT only for the data displayed in the chart (skipping the data “off-the-chart”), thereby allowing it to automatically adjust the MVPT level factor to the average price of the left-most bar. This leaves the analyst only the simple task of adjusting the scaling parameter for a visually-pleasing presentation. As seen in Figure 1, we’re able to automatically detect divergences, although that part of the code is not given here in the interest of space and clarity.


Image

Figure 1. A recent example of MVPT/Price divergence can be found in the Natural Gas ETF, UNG, which has potentially formed a double bottom. A strong break above the trend line resistance could very well signal the start of a larger move higher.


WealthScript Code (C#)

using System; using System.Collections.Generic; using System.Text; using System.Drawing; using WealthLab; using WealthLab.Indicators; using WealthLab.ChartStyles; /* Note */

namespace WealthLab.Strategies { public class MyStrategy : WealthScript { StrategyParameter _scale; StrategyParameter _level; StrategyParameter _pctRev; public MyStrategy() { _scale = CreateParameter("Scale", 1, 1, 10000, 1); _level = CreateParameter("Level (disabled)", 0, 0, 10000, 100); _pctRev = CreateParameter("Reverse %", 10, 1, 25, 1); }

protected override void Execute() { double rev = _pctRev.Value; BarChartStyle bcs = null; try { bcs = (BarChartStyle)ChartStyle; } catch { DrawLabel(PricePane, "Please switch to Bar (OHLC) Chart Style", Color.Red); return; } int b = bcs.LeftEdgeBar; DataSeries mVPT = new DataSeries(Bars, "Modified VPT"); DataSeries avg4 = (Open + High + Low + Close) / 4d; _level.Value = avg4b; DataSeries avg4_1 = avg4 >> 1; DataSeries change = (avg4 - avg4_1) / avg4_1; // changed from *= (Volume / 50000d); // to compensate a little for diverse ranges of Volume change *= ( Volume / Math.Pow(10, Math.Log10(SMA.Value(Bars.Count - 1, Volume, 50))) ); for (int bar = b; bar < Bars.Count; bar++) { mVPTbar = ( mVPTbar - 1 + changebar ); } mVPT *= _scale.Value; mVPT += _level.Value; PlotSeries(PricePane, mVPT, Color.Teal, LineStyle.Solid, 2); } } }

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.