Swing AFL for ATR Bands Strategy

Contents

Step 1: The Trading Idea

Buy when prices “suddenly” move upward; sell when prices suddenly move downward

Step 2: Selecting Indicators for ATR Trading System

Often a change in trend is indicated by a quick or sudden move in the direction of change. This sudden move also indicates momentum in the new direction.

We try to exploit this trading idea using ATR bands. The ATR bands are plotted by adding/subtracting the ATR value to moving average. The exponential moving average (EMA) indicates the average price movement. When prices move above the EMA+ATR level, it indicates a sudden upmove, or an upwards thrust.

The ATR bands are truly trend following in the sense that they are constructed using moving average +/- atr value. These are also smoother than Bollinger bands because thye use ATR instead of Standard Deviations. Since we are testing on 15 minute time frame, we use 50 periods EMA for ATR bands to generate fewer signals. The ATR Bands are also called Keltner Bands.

Step 3: Defining Clear Strategy Rules for ATR Bands Strategy

Buy: When price cross above the upper ATR band

Sell:  When prices cross below the lower ATR band

AFL for ATR Bands Strategy

Please note that this is a signal-to-signal, or a stop-and-reverse strategy.

Step 4: AFL Coding Guide

The AFL code is pretty straightforward. Care is taken to define Buy, Sell, Short and Cover properly. The signal cycles are checked in default code to ensure proper signal occurrence.

Step 5: The Backtest

The strategy is significantly profitable in Bank Nifty current month futures. It generates a profit of 6646 points, or Rs. 4,98,450/ over two years on one lot (75 shares). The winner% is 47.73, which is a quite good for a trend following stop-and-reverse strategy.

Related Article: Basics in Strategy Backtesting

  • Scrip: Bank Nifty current month futures, 15-minute
  • All trades executed at Close price of the bar on which signal is triggered
  • Brokerage: 0.01% of Trade Value
  • Data History: 01-01-2014 to 31-12-2015 (two years)
  • Strategy Optimization: None

Step 6: Further Improvement

We leave it to the readers to suggest any improvement in Step 2 and Step 3 which can increase the profitability. We can introduce custom stoploss as well as profit targets to further maximize the profitability.

Download here AFL for ATR Bands Strategy

Click here to download the editable Amibroker AFL for ATR Bands Strategy

Click here to learn about Keltner Bands on Chart School