Amibroker ADX AFL - AlgoJi

Step 1: The Trading Idea

We try to buy when a) trend is strong b) exit when trend is weak.

Step 2: Selecting Indicators for ADX AFL Trading System

The ADX is perhaps the most popular trend detection indicator, developed by Welles Wilder.  The Plus Directional Index (PDI) is calculated as the current high minus the prior high, provided it is positive. It is assigned a value of zero if not positive. The Minus Directional Index (MDI) is calculated as the prior low minus the current low, provided it is positive. It is also assigned a value of zero if this figure is not positive.

PDI indicates the strength of uptrend while MDI indicates the strength of downtrend. A low value of PDI or MDI suggests that there is not any clear trend in market.

Currently we do not add any other indicator to this system to test the technical strength of ADX.

Step 3: Defining Clear Strategy Rules

Buy: Buy When PDI crossed above MDI, the value of PDI is greater than 25  and value of MDI is less than 25.

Sell:  When PDI falls below MDI.

ADX Buy Sell System

Step 4: AFL Coding Guide

This is perhaps the simplest afl trading system in which the afl code can be understood by non-programmers also. We carefully define the Buy, Sell, Short and Cover rules; where Short and Cover are symmetrically opposite if Buy and Sell. This helps in smooth integration of this AFL with automated trading systems

Step 5: The Backtest

The strategy is significantly profitable in Bank Nifty current month futures. It generates a profit of 6214 points, or Rs. 4,66,050/ over two years on one lot (75 shares). The winner% is 38.06, which is slightly low for a purely 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 introduce custom stoploss as well as profit targets to further maximize the profitability.

Download ADX AFL trading System

Click here to download the editable Amibroker AFL Strategy