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

Modified on 2010/09/12 11:37 by Eugene — Categorized as: TASC Traders Tips

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 = avg4[b]; 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++) { mVPT[bar] = ( mVPT[bar - 1] + change[bar] ); } mVPT *= _scale.Value; mVPT += _level.Value; PlotSeries(PricePane, mVPT, Color.Teal, LineStyle.Solid, 2); } } }