TASC 2018-04 | Adaptive Moving Averages (Apirine)

Modified on 2018/02/28 07:24 by Eugene — Categorized as: TASC Traders Tips

Traders' Tip text

In an attempt to improve the situation with many whipsaw signals typically generated by price/KAMA crossovers, Vitali Apirine combines two adaptive moving averages to create a simple AMA/KAMA crossover system. By installing TASCIndicators library's latest version from our website and restarting Wealth-Lab, users can rebuild this system from the flexible blocks known as Rules. By simply combining and reordering them one can come up with pretty elaborate strategies. Figure 1 illustrates the easiness – the process can take less than a minute and free you up from writing the code.

Image

Figure 1. Setting up the system in Wealth-Lab's “Rules Wizard”.

The system naturally works better on stocks which steadily move in the direction of the trend rather than go sideways (even with higher volatility) or less volatile ones. It's the sideway movement that is one of the biggest performance killers of a moving average system like this. A market filter might help further avoid whipsaws.

Image

Figure 2. Successful trend trades followed by losses in sideways market in INTC (Intel).

For those of you who like to customize every aspect and build even more complex logic, C# language and the power of .NET framework is at your disposal in Wealth-Lab:

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

namespace WealthLab.Strategies { public class MyStrategy : WealthScript { protected override void Execute() { var ama = AMA.Series( Bars, 10); var kama = KAMA.Series( Close, 10);

PlotSeries( PricePane, ama,Color.Red,LineStyle.Solid,2); PlotSeries( PricePane, kama,Color.DarkGreen,LineStyle.Solid,2);

for(int bar = GetTradingLoopStartBar(11 * 3); bar < Bars.Count; bar++) { if ( IsLastPositionActive ) { Position p = LastPosition; if ( CrossUnder( bar, ama, kama)) SellAtMarket( bar + 1, p); } else { if ( CrossOver( bar, ama, kama)) BuyAtMarket( bar + 1); } } } } }


Eugene (Gene Geren)
Wealth-Lab team
www.wealth-lab.com