KeltnerATR_Lower

Modified on 2010/09/13 15:30 by Eugene — Categorized as: Community Indicators

Syntax

public KeltnerATR_Lower(Bars bars, int smaPeriod, int atrPeriod, double atrMult, string description)
public static KeltnerATR_Lower(Bars bars, int smaPeriod, int atrPeriod, double atrMult)

Parameter Description

bars The Bars object
smaPeriod Length used to calculate the center line
atrPeriod The period to smooth Average True Range
atrMult Multiple of the average true range used to determine the modified Keltner Channel bands.

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: KeltnerLower, KeltnerUpper.

This modification of Keltner indicators is different from Wealth-Lab's built-in, classic Keltner Bands: it uses ATR units to construct the upper and lower bands, specified in the atrMult parameter. See also: KeltnerATR_Upper.

Interpretation


Calculation

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

Center Line = smaPeriod bar SMA of AP

Upper Band = Center Line + atrMult times ATR(atrPeriod)

Lower Band = Center Line - atrMult times ATR(atrPeriod)

Example


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

namespace WealthLab.Strategies { public class MyStrategy : WealthScript { protected override void Execute() { Color cool = Color.FromArgb( 50, Color.Blue ); KeltnerATR_Lower K1 = KeltnerATR_Lower.Series( Bars, 10, 10, 2 ); KeltnerATR_Upper K2 = KeltnerATR_Upper.Series( Bars, 10, 10, 2 ); PlotSeriesFillBand( PricePane, K1, K2, cool, cool, 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 ); } } } } } }