MACD AFL Strategy

Since MACD gives good signals in trending market, to develop a macd afl strategy, we need filters to avoid sideways market and trade only when momentum is healthy.

Contents

Step 1: The Trading Idea

We try to buy when a) trend is strong b) there is momentum in market c) the market is not sideways

Step 2: Selecting Indicators for MACD AFL Strategy

The MACD indicator is one of the most popular indicators to determine trending prices.  The basic trading rules suggested by its founder Gerald Appel is to buy when it cuts above zero line or buy when its cuts above signal line. When the direction of trend is not clear, MACD stays close to the zero line. Hence we use smooth MACD(30,50,60) to determine trend and do no trade when it’s value is between -25 to +25 (close to zero).

When the market is dull, the prices move slowly and seldom go beyond their standard deviation levels. So we use Bollinger Band(20,1) to filter out signals generated when prices are between them.

Step 3: Defining Clear Strategy Rules

Buy: MACD>0 and MACD> Signal Line and MACD>25 and Signal candle is beyond Bollinger Band

Sell:  When either MACD<0 or MACD< Signal Line

MACD AFL

Step 4: AFL Coding Guide (Non-repainting)

The AFL coding part for this strategy is really straightforward. Even if you are non-programmer, you will find the AFL code intuitive and easy to understand.

Step 5: The Backtest

The strategy is significantly profitable in Bank Nifty current month futures. It generates a profit of 4020 points, or Rs. 3,01,500/ over two years on one lot. The winner% is 43.66, which is fair for a trend based 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 intoduce custom stoploss as well as profit targets to further maximize the profitability.

Download MACD AFL Amibroker Strategy

Click here to download the editable Amibroker AFL Strategy