afl of the week- a profitable trend following system

Upload: anjali-srivastava

Post on 07-Jul-2018

215 views

Category:

Documents


0 download

TRANSCRIPT

  • 8/18/2019 AFL of the Week- A Profitable Trend Following System

    1/3

    Tradingtuitions.com

    AFL of the week: A profitable trend following system2016-02-28 00:02:38 admin

    This strategy is based on MACD, RSI, Stochastic and Exponential moving average. Combination of all these indicators assures good returns with minimum whipsaws. Inthe chart, uptrends are represented by blue colour and downtrends are represented by red colour.

    Read our article on AFL tutorial here.

    AFL Overview

    Paramter ValuePreferred Timeframe Daily, Hourly

    Indicators Used MACD, Stochastic, RSI, EMA

    Buy Condition

    RSI period 3 greater than 50, Difference between MACD and

    MACD signal line is greater than 0 and also greater than that of 

    previous candle, Stochastic %D line is less than 80 and greater 

    than that of previous candle, Closing price greater than EMA

    period 100.

    Sell Condition

    RSI period 3 less than 50, Difference between MACD and

    MACD signal line is less than 0 and also less than that of 

    previous candle, Stochastic %D line is greater than 20 and less

    than that of previous candle, Closing price less than EMA

    period 100.

    Stop Loss 2.5%

    Targets No fixed target, Stop and reverse when AFL gives opposite signal

    Position Size 300(fixed)

    Initial Equity 200000

    Brokerage 50 per order 

    Margin 10%

    AFL Code

    //------------------------------------------------------

    //

    // Formula Name: Trend following trading System

    // Author/Uploader: Trading Tuitions

    // E-mail: [email protected]// Website: www.tradingtuitions.com

    //------------------------------------------------------

    _SECTION_BEGIN("Trend following Trading system");

    SetTradeDelays( 1, 1, 1, 1 );

    SetOption( "InitialEquity", 200000);

    SetOption("FuturesMode" ,True);

    SetOption("MinShares",1);

    SetOption("CommissionMode",2);

    SetOption("CommissionAmount",50);

    SetOption("AccountMargin",10);

    SetOption("RefreshWhenCompleted",True);

    SetPositionSize(300,spsShares);

    SetOption( "AllowPositionShrinking", True );

    BuyPrice=Open;

    SellPrice=Open;ShortPrice=Open;

    CoverPrice=Open;

    SetChartOptions(0,chartShowArrows|chartShowDates);

    _N(Title = StrFormat("{{NAME}} - {{INTERVAL}} {{DATE}} Open %g, Hi %g, Lo %g, Close %g (%.1f%%) {{VALUES}}", O, H, L, C, Se

    SD = StochD(8, 3, 3);

    MH = MACD(8, 21) - Signal(8, 21, 5);

    trendup = IIf(MH > 0 OR (MH > 0 AND MH > Ref(MH, -1)) AND RSI(3) >50 AND SD < 80 AND SD > Ref(SD, -1) AND ValueWhen(C,O

    EMA20=EMA(Close,100);

    Buy=MH > 0 OR (MH > 0 AND MH > Ref(MH, -1)) AND RSI(3) >50 AND SD < 80 AND SD > Ref(SD, -1) AND ValueWhen(C,OC);

    Buy = Buy AND Close>EMA20;

    Sell=Sell AND Close

  • 8/18/2019 AFL of the Week- A Profitable Trend Following System

    2/3

    PlotShapes(IIf(Buy, shapeSquare, shapeNone),colorGreen, 0, L, Offset=-40);

    PlotShapes(IIf(Buy, shapeSquare, shapeNone),colorLime, 0,L, Offset=-50);

    PlotShapes(IIf(Buy, shapeUpArrow, shapeNone),colorWhite, 0,L, Offset=-45);

    PlotShapes(IIf(Cover, shapeSquare, shapeNone),colorGreen, 0, L, Offset=-40);

    PlotShapes(IIf(Cover, shapeSquare, shapeNone),colorLime, 0,L, Offset=-50);

    PlotShapes(IIf(Cover, shapeUpArrow, shapeNone),colorWhite, 0,L, Offset=-45);

    PlotShapes(IIf(Sell, shapeSquare, shapeNone),colorRed, 0, H, Offset=40);

    PlotShapes(IIf(Sell, shapeSquare, shapeNone),colorOrange, 0,H, Offset=50);

    PlotShapes(IIf(Sell, shapeDownArrow, shapeNone),colorWhite, 0,H, Offset=-45);

    PlotShapes(IIf(Short, shapeSquare, shapeNone),colorRed, 0, H, Offset=40);

    PlotShapes(IIf(Short, shapeSquare, shapeNone),colorOrange, 0,H, Offset=50);

    PlotShapes(IIf(Short, shapeDownArrow, shapeNone),colorWhite, 0,H, Offset=-45);

    Plot( C, "Close", trendcolor, styleCandle | styleThick );

    Plot(EMA20,"EMA",colorBlue);

    _SECTION_END();

    AFL Screenshot

     

    Backtest Report

     Paramter Value  NSE BankNifty

    Initial Capital 200000

    Final Capital 5370094.50

    Backtest Period 09-06-2000 to 26-02-2016

    Timeframe Daily

    Net Profit % 2585.05%

     Annual Return % 22.58%

    Number of Trades 110

    Winning Trade % 28.18%

     Average holding Period 30.73 periods

    Max consecutive losses 12

    Max system % drawdown -56.04%

    Max Trade % drawdown -62.51%

    Download the detailed backtest report here.

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

    Equity Curve

    http://tradingtuitions.com/wp-content/uploads/2016/02/Trend-Following-Backtest-Report.html

  • 8/18/2019 AFL of the Week- A Profitable Trend Following System

    3/3

     

    Additional Amibroker settings for backtesting

    Goto Symbol–>Information, and specify the lot size and margin requirement. The below screenshot shows lot size of 30 and margin requirement of 10% for Bank 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 onthem. 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 [email protected]

    Liked this article? Please spare few seconds to share it. Share on FacebookShare on TwitterShare on Google+Share on Linkedin

    Related 

    http://www.linkedin.com/shareArticle?mini=true&url=http%3A%2F%2Ftradingtuitions.com%2Fafl-of-the-week-a-profitable-trend-following-system%2F&title=AFL+of+the+week%3A+A+profitable+trend+following+systemhttps://plus.google.com/share?url=http%3A%2F%2Ftradingtuitions.com%2Fafl-of-the-week-a-profitable-trend-following-system%2Fhttp://twitter.com/intent/tweet/?text=AFL+of+the+week%3A+A+profitable+trend+following+system&url=http%3A%2F%2Ftradingtuitions.com%2Fafl-of-the-week-a-profitable-trend-following-system%2Fhttp://www.facebook.com/sharer/sharer.php?u=http%3A%2F%2Ftradingtuitions.com%2Fafl-of-the-week-a-profitable-trend-following-system%2F