TASC 2016-08 | The Middle-High-Low Range Moving Average (Apirine)

Modified on 2016/06/30 12:25 by Eugene — Categorized as: TASC Traders Tips

Traders' Tip text

The middle-high-low moving average by Vitali Apirine is a double smoothed indicator. It's simply a moving average applied to the middle of the high-low range. Like any moving average which helps determine the direction of a trend, it can be applied following same guidelines for using a moving average. Although our rendition uses either SMA or EMA to smooth the raw MHA, power users can utilize any of the many moving averages already available in Wealth-Lab.

Image

Figure 1 illustrates the application of the system's rules on the Daily chart of “RUT (Russell 2000)

After updating the TASCIndicators library to v2016.07 or later, the MHLMA indicator can be found under the TASC Magazine Indicators group. It can be plotted on a chart and be used as an entry or exit condition in a Rule-based Strategy without having to program a line of code yourself.

The Wealth-Lab Strategy lets you choose between SMA or EMA to build the MHLMA as well as to set the highest/lowest range and smoothing lookback periods interactively through "parameter sliders" on the bottom left of the screen.

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

namespace WealthLab.Strategies { public class TASC201608 : WealthScript { private StrategyParameter slider1; private StrategyParameter slider2; private StrategyParameter slider3; public TASC201608() { slider1 = CreateParameter("MHL Period",3,2,300,20); slider2 = CreateParameter("MA Period",10,2,300,20); slider3 = CreateParameter("SMA(0) or EMA (1)",0,0,1,1); } protected override void Execute() { int movAvgPeriod = slider2.ValueInt; bool isEMA = slider3.ValueInt == 0 ? false : true; var mhl = MHLMA.Series(Bars,slider1.ValueInt,slider2.ValueInt, isEMA ? WhichMA.EMA : WhichMA.SMA); DataSeries ema = EMA.Series(Close,movAvgPeriod,EMACalculation.Modern); DataSeries sma = SMA.Series(Close,movAvgPeriod);

PlotSeries(PricePane,mhl,Color.Red,LineStyle.Solid,1); PlotSeries(PricePane,isEMA ? ema : sma,Color.DarkGreen,LineStyle.Solid,1);

for(int bar = GetTradingLoopStartBar(1); bar < Bars.Count; bar++) { if (IsLastPositionActive) { if( CrossUnder(bar,isEMA?ema:sma,mhl) ) SellAtMarket(bar+1, LastPosition); } else { if( CrossOver(bar,isEMA?ema:sma,mhl) ) BuyAtMarket(bar+1, isEMA.ToString()); } } } } }


Eugene
Wealth-Lab team
www.wealth-lab.com