10

AFL of the week: Support Resistance based Trading System

This is a breakout strategy where buy/sell signal is generated when price crosses a dynamic support/resistance. The calculation of support/resistance is based on highest high value and lowest low value for a particular lookback period. This strategy seems to work well in Trending markets.

Please visit Trading Tuitions Academy to learn AFL coding and create your own Trading systems.

AFL Overview

Paramter Value
Preferred Timeframe Daily, Hourly
Indicators Used None
Buy Condition Price crosses above dynamic resistance.
Sell Condition Price crosses below dynamic support.
Stop Loss 2%
Targets No fixed target, Stop and reverse when AFL gives opposite signal
Position Size 150 (fixed)
Initial Equity 200000
Brokerage 50 per order
Margin 10%

AFL Code

Click here to download AFL code for this system.

AFL Screenshot

Dynamic Support Resistance

Backtest Report

 Parameter Value
  NSE Nifty
Initial Capital  200000
Final Capital 1275626.60
Backtest Period 01-Jan-2007 to 19-02-2016
Timeframe Daily
Net Profit %  537.81%
Annual Return % 22.48%
Number of Trades 243
Winning Trade % 41.56%
Average holding Period 8.93 periods
Max consecutive losses 6
Max system % drawdown -28.78%
Max Trade % drawdown -60.73%

Download the detailed backtest report here.

Please note that you can expect even better results if you allow compounding of your returns.

Equity Curve

EquityCurve_DynamicSupRes

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:

Symbol Info_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

Related Posts

10 Comments

  1. Dear Sir,
    Error showing in line 36, 38, 39 & 40.
    Kindly have a look.
    And thanks for the efforts.

      • Thanks a lot. Back testing in daily & hourly tf showing great results.
        Bye the way, “The calculation of support/resistance is based on highest high value and lowest low value for a particular lookback period. ”

        What is period here? Can we change it to suit lower tf?

        • Hi Gautam,
          The default lookback period is 3 as per the below code:
          period=Optimize(“Swing”,3,1,25,1);
          You can definitely change it to suit different timeframes and symbols. For ex: Lookback period of 4 works great in BankNifty

  2. How to make this AFL close all trades at a particular time?
    And also open a new trade at the start of the day.

    • Hi Ethinix,

      You’ll have to mention the time in the COVER and SELL conditions.

  3. period=Optimize(“Swing”,3,1,25,1);
    From the comments above, I could perceive that 3 is the look back period. What does 1,25,1 inputs signify?

Leave a Reply

Your email address will not be published.