KeltnerLower

Modified on 2008/04/17 13:31 by Administrator — Categorized as: Standard Indicators

Syntax

public KeltnerLower(Bars bars, int periodOne, int periodTwo, string description) public static KeltnerLower Series(Bars bars, int periodOne, int periodTwo)

Parameter Description

bars The Bars object
periodOne The period to smooth Highs-Lows
periodTwo The period to smooth Average Price

Description

Keltner Bands are a type of price channel first described by Chester W. Keltner in his book How to Make Money in Commodities. They are fixed bands that are plotted above and below a simple moving average (SMA) of average price (AveragePriceC). See also: KeltnerUpper.

The Keltner indicators in Wealth-Lab take two parameters. periodOne specifies the period to smooth highs - lows, and periodTwo specifies the period to use to smooth Average Price in the calculation (see below). Note that because Keltner Bands are defined to use average price, and highs minus lows, the indicator does not take a Price Series parameter like many other indicator functions.

Interpretation


Calculation

Average Price (AP) = (Close + High + Low ) / 3

Band Moving Average = Period1 bar Simple Moving Average (SMA) of (High - Low)

Center Line = Period2 bar SMA of AP

Upper Band = Center Line + Band MA

Lower Band = Center Line - Band MA

Example

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 = KeltnerLower.Series( Bars, 10, 10 ); DataSeries K2 = KeltnerUpper.Series( Bars, 10, 10 ); PlotSeriesFillBand( PricePane, K1, K2, Color.Blue, Color.Empty, LineStyle.Solid, 2);

for(int bar = 30; bar < Bars.Count; bar++) { if( !IsLastPositionActive ) { if( CrossOver( bar, Close, K2 ) ) BuyAtMarket( bar+1 ); else if( CrossUnder( bar, Close, K1 ) ) ShortAtMarket( bar+1 ); } else { Position p = LastPosition; if( CrossOver( bar, Close, K2 ) & p.PositionType != PositionType.Long ) { CoverAtMarket( bar+1, p ); BuyAtMarket( bar+1 ); } if( CrossUnder( bar, Close, K1 ) & p.PositionType == PositionType.Long ) { SellAtMarket( bar+1, p ); ShortAtMarket( bar+1 ); } } } } } }