Shifted Moving Average

Modified on 2010/10/01 14:15 by Eugene — Categorized as: Community Indicators

ShiftedMA: Indicator Documentation

Syntax

DataSeries ShiftedMA( DataSeries ds, int period, int delay, ChoiceOfMA option );

Parameter Description

ds Data series used to produce the moving average calculation
period Period to average the data series
delay Period to offset the moving average to the right
option Select between the moving average types: SMA, EMA, WMA or SMMA (smoothed MA)

Description

The Shifted Moving Average (ShiftedMA) is not a cool new moving average. It is nothing but a typical moving average (that can be SMA, EMA or WMA) delayed by the user specified offset. The purpose of this indicator is to facilitate the use of delays in rule-based Strategies. In code-based Strategies, this is simply a matter of using the DataSeries offset (>> or <<, see DataSeries in the QuickRef).

Example

This example illustrates how to use the ShiftedMA indicator, comparing an EMA with its delayed version:


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 shiftedMA_demo : WealthScript { protected override void Execute() { ShiftedMA delayedEMA = ShiftedMA.Series( Close, 20, 2, ChoiceOfMA.EMA ); DataSeries ema = EMAModern.Series( Close, 20 ); PlotSeries( PricePane, ema, Color.Red, LineStyle.Solid, 2 ); PlotSeries( PricePane, delayedEMA, Color.Blue, LineStyle.Solid, 1 ); } } }