Similar to Donchian Band, Keltner Band is another promising indicator to determine trend breakouts accurately. And experienced traders might very well know that catching accurate trend breakouts is as good a finding a fortune. Keltner band calculates the price range based on ATR (average true range), which is different from standard deviation calculation that Bollinger band uses. In this post, we would understand Keltner band calculation steps and explore a trading system based on it. This trading system is backtested on NSE Nifty for past 18 years and results are decent enough.
Please visit Trading Tuitions Academy to learn AFL coding and create your own Trading systems.
Keltner Band Calculation Steps
Keltner Band is named after Chester W. Keltner (1909–1998) who described it in his 1960 book How To Make Money in Commodities.
The band can be visualized a central moving average line enveloped by an upper and lower band. These bands are calculated based on average true range(ATR) of the price.
Below is the standard calculation steps for Keltner band.
Middle line = 20 period moving average
Keltner Upper Band = Middle line + Multiplier * ATR(Periods)
Keltner Lower Band = Middle line – Multiplier * ATR(Periods)
The default value of multiplier is 2, and periods is 10.
All the constants used in the calculation steps can be adjusted based on the security and timeframe you are trading.
Keltner Band Trading System – AFL Overview
Parameter | Value |
Preferred Time-frame |
Daily |
Indicators Used | ATR, Bollinger Bands |
Buy Condition | High value of candle crosses above Keltner upper band |
Short Condition | Low value of candle crosses below Keltner lower band |
Sell Condition | Low value of candle crosses below Keltner middle band |
Cover Condition | High value of candle crosses above Keltner middle band |
Stop Loss | No defined SL |
Targets | No defined target |
Position Size | 150 (fixed) |
Initial Equity | 200000 |
Brokerage | 100 per order |
Margin | 10% |
Keltner Band Trading System – AFL Code
//------------------------------------------------------ // // Formula Name: Keltner Channel trading System // Author/Uploader: Trading Tuitions // E-mail: support@tradingtuitions.com // Website: www.tradingtuitions.com //------------------------------------------------------ _SECTION_BEGIN("Keltner Channel trading System"); SetChartOptions(0,chartShowArrows|chartShowDates); _N(Title = StrFormat("{{NAME}} – {{INTERVAL}} {{DATE}} Open %g, Hi %g, Lo %g, Close %g (%.1f%%) {{VALUES}}", O, H, L, C, SelectedValue( ROC( C, 1 ) ) )); //Initial Parameters SetTradeDelays( 0,0,0, 0 ); SetOption( "InitialEquity", 200000); SetOption("FuturesMode" ,True); SetOption("MinShares",1); SetOption("CommissionMode",2); SetOption("CommissionAmount",50); SetOption("AccountMargin",10); SetOption("RefreshWhenCompleted",True); SetPositionSize(150,spsShares); SetOption( "AllowPositionShrinking", True ); Plot( Close, "Price", colorWhite, styleCandle ); //Keltner Band Code KMid = MA (Close, 20); //Middle Line ATRPeriod = 10; //ATR Period KFactor = 2; //Multiplier KValue = ATR(ATRPeriod) * KFactor; KTop = KMid + KValue; //Upper Band KBottom = KMid - KValue; //Lower Ban printf("\nKTop : " + KTop ); printf("\nKBottom : " + KBottom ); printf("\nKMid : " + KMid ); Plot(KTop,"KTop",colorBlue,styleLine); Plot(KMid,"KMid",colorGreen,styleLine); Plot(KBottom,"KBottom",colorRed,styleLine); Buy=Cross(High,KTop); Short=Cross(KBottom,Low); Sell=Cross(KMid,Low); Cover=Cross(High,KMid); BuyPrice=KTop; SellPrice=KMid; ShortPrice=KBottom; CoverPrice=KMid; Buy = ExRem(Buy,Sell); Sell = ExRem(Sell,Buy); Short=ExRem(Short,Cover); Cover=ExRem(Cover,Short); printf("\nBuy : " + Buy ); printf("\nSell : " + Sell ); printf("\nShort : " + Short ); printf("\nCover : " + Cover ); /* Plot Buy and Sell Signal Arrows */ PlotShapes(IIf(Buy, shapeSquare, shapeNone),colorGreen, 0, L, Offset=-25); PlotShapes(IIf(Buy, shapeSquare, shapeNone),colorLime, 0,L, Offset=-35); PlotShapes(IIf(Buy, shapeUpArrow, shapeNone),colorWhite, 0,L, Offset=-30); PlotShapes(IIf(Short, shapeSquare, shapeNone),colorRed, 0, H, Offset=25); PlotShapes(IIf(Short, shapeSquare, shapeNone),colorOrange, 0,H, Offset=35); PlotShapes(IIf(Short, shapeDownArrow, shapeNone),colorWhite, 0,H, Offset=-30); PlotShapes(IIf(Sell, shapeStar, shapeNone),colorGold, 0, L, Offset=-15); PlotShapes(IIf(Cover, shapeStar, shapeNone),colorGold, 0,L, Offset=-15); _SECTION_END();
AFL Screenshot
Below is the screenshot of the Keltner Band AFL chart from Amibroker
Also Read: Intraday trend following strategy: MACD and Bollinger Bands
Keltner Band Trading System- Backtest Report
The performance of this system may not be as impressive as Donchian band trading system, but still it’s a stable system and gives very accurate signals. Try it out on different instruments
Parameter | Value |
Nifty | |
Initial Capital | 200000 |
Final Capital | 998020.42 |
Scrip Name | NSE Nifty |
Backtest Period | 09-Feb-2000 to 18-May-2018 |
Timeframe | Daily |
Net Profit % | 399.01% |
Annual Return % | 9.14% |
Number of Trades | 198 |
Winning Trade % | 42.42% |
Average holding Period | 14.74 periods |
Max consecutive losses | 4 |
Max system % drawdown | -29.49% |
Max Trade % drawdown | -87.55% |
Download the detailed backtest report here.
Equity Curve
The equity curve is consistent and almost linear
Profit Table
Additional Amibroker settings for backtesting
Goto Symbol–>Information, and specify the lot size and margin requirement. The below screenshot shows lot size of 75 and margin requirement of 10% for NSE Nifty:
Disclaimer:
All the AFL’s posted in this section are for learning purpose. Trading Tuitions does not necessarily own these AFL’s and we don’t have any intellectual property rights on them. We might copy useful AFL’s from public forums and post it in this section in a presentable format. The intent is not to copy anybody’s work but to share knowledge. If you find any misleading or non-reproducible content then please inform us at support@tradingtuitions.com
For a period of 18 years –
Net Profit % 399.01%
Annual Return % 9.14%
this seems like a really low performing trading system. 9.14% p.a. is like having a ROI slightely better than FD.
am I missing something here?
Keltner Band should give a very very good return if configured well. Could you share any other better example, a better test of Keltner Band trading system?