Modified on 2008/04/18 09:02 by Administrator — Categorized as: Standard Indicators


public KAMA(DataSeries source, int period, string description)
public static KAMA Series(DataSeries source, int period)

Parameter Description

source The source DataSeries
period Indicator calculation period


Returns Kaufman's Adaptive Moving Average for the DataSeries specified in the source parameter. KAMA is an adaptive moving average, and uses the noise level of the market to determine the length of the trend required to calculate the average. The more noise in the market, the slower the trend used to calculate the average. The period parameter controls how much data is used by KAMA to calculate its efficiency ratio (signal/noise). A value of 8 to 10 is recommended.



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

namespace WealthLab.Strategies { public class MyStrategy : WealthScript { protected override void Execute() { DataSeries K1 = KAMA.Series( Close, 8 ); DataSeries K2 = KAMA.Series( Close, 16 ); PlotSeries( PricePane, K1, Color.Red, WealthLab.LineStyle.Solid, 1 ); PlotSeries( PricePane, K2, Color.Maroon, WealthLab.LineStyle.Solid, 1 );

// Note that KAMA is considered to be an "unstable" indicator; hence the bar loop starts at 50 for(int bar = 50; bar < Bars.Count; bar++) { if (IsLastPositionActive) { if( CrossUnder( bar, K1, K2 ) ) SellAtMarket( bar+1, LastPosition ); } else { if( CrossOver( bar, K1, K2 ) ) BuyAtMarket( bar+1 ); } } } } }