• Australian (ASX) Stock Market Forum

Hello and welcome to Aussie Stock Forums!

To gain full access you must register. Registration is free and takes only a few seconds to complete.

Already a member? Log in here.

Amibroker Trading System Collection with Backtest Report

Discussion in 'Trading Strategies/Systems' started by snehil2010, Dec 20, 2016.

  1. snehil2010

    snehil2010

    Posts:
    4
    Likes Received:
    0
    Joined:
    Sep 20, 2016
    Hi,

    Thought of sharing a good collection of trading systems coded in Amibroker with their respective backtest report. Each of these systems are backtested on Indian stocks/indices. I have personally tried some of them on ASX stocks too and it looks good. Please share your thoughts whether they can be used for live trading.

    Dropbox Link: https://www.dropbox.com/s/k2zbxzd6cn0nnex/Trading Systems.zip?dl=0

    Could not directly attach the PDF's because of file size limit.

    PS: I am not associated with the original author or website, just sharing it for gudance from senior traders of the forum.

    Thanks,
    Snehil
     
  2. jjbinks

    jjbinks

    Posts:
    306
    Likes Received:
    267
    Joined:
    May 14, 2013
  3. snehil2010

    snehil2010

    Posts:
    4
    Likes Received:
    0
    Joined:
    Sep 20, 2016
    One of the system which looks most promising is called "Intraday Trading Strategy for Nifty". Nifty is an Indian Index. The strategy is based on RSI and ADX and the CAGR is quite impressive.

    Code:
    //------------------------------------------------------
    //
    //  Formula Name:    Nifty Intraday Strategy using RSI and ADX
    //  Author/Uploader: Trading Tuitions
    //  E-mail:          support@tradingtuitions.com
    //  Website:         www.tradingtuitions.com
    //------------------------------------------------------
    
    _SECTION_BEGIN("Nifty Intraday Strategy");
    
    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(150,spsShares); //Use this for fixed position size
    //SetPositionSize(80,spsPercentOfEquity); //Use this for position size as a percent of Equity
    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 ));
    
    Plot( Close, "Price", colorWhite, styleCandle );
    
    RSIPeriods=17;
    ADXPeriods=14;
    
    Buy=RSI(RSIPeriods)>=75 AND ADX(ADXPeriods)>25;
    Short=RSI(RSIPeriods)<=25 AND ADX(ADXPeriods)>25 ;
    
    Buy=ExRem(Buy,Short);
    Short=ExRem(Short,Buy);
    
    Sell=Short OR TimeNum()==151500;
    Cover=Buy OR TimeNum()==151500;
    
    StopLoss=0.5;
    ApplyStop(Type=0,Mode=1,Amount=StopLoss);
    
    Plot( RSI(RSIPeriods), "RSI", color=colorBlue, ParamStyle( "Style", styleOwnScale) );
    Plot( ADX(ADXPeriods), "ADX", color=colorRed, ParamStyle( "Style", styleOwnScale) );
    
    /* Plot Buy and Sell Signal Arrows */
    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);
    
    _SECTION_END();
    
    
    The backtest report for this strategy is as below:

    Nifty Intraday Backtest.PNG
     
  4. snehil2010

    snehil2010

    Posts:
    4
    Likes Received:
    0
    Joined:
    Sep 20, 2016
    Most of these strategies look good, but there is one which particularly catched my attention. It is a simple strategy involving RSI and ADX but the profit potential is pretty good. Monte Carlo analysis also shows good results. See the AFL code and backtest report below.

    Code:
    //------------------------------------------------------
    //
    //  Formula Name:    Nifty Intraday Strategy using RSI and ADX
    //  Author/Uploader: Trading Tuitions
    //  E-mail:          support@tradingtuitions.com
    //  Website:         www.tradingtuitions.com
    //------------------------------------------------------
    
    _SECTION_BEGIN("Nifty Intraday Strategy");
    
    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(150,spsShares); //Use this for fixed position size
    //SetPositionSize(80,spsPercentOfEquity); //Use this for position size as a percent of Equity
    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 ));
    
    Plot( Close, "Price", colorWhite, styleCandle );
    
    RSIPeriods=17;
    ADXPeriods=14;
    
    Buy=RSI(RSIPeriods)>=75 AND ADX(ADXPeriods)>25;
    Short=RSI(RSIPeriods)<=25 AND ADX(ADXPeriods)>25 ;
    
    Buy=ExRem(Buy,Short);
    Short=ExRem(Short,Buy);
    
    Sell=Short OR TimeNum()==151500;
    Cover=Buy OR TimeNum()==151500;
    
    StopLoss=0.5;
    ApplyStop(Type=0,Mode=1,Amount=StopLoss);
    
    Plot( RSI(RSIPeriods), "RSI", color=colorBlue, ParamStyle( "Style", styleOwnScale) );
    Plot( ADX(ADXPeriods), "ADX", color=colorRed, ParamStyle( "Style", styleOwnScale) );
    
    /* Plot Buy and Sell Signal Arrows */
    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);
    
    
    _SECTION_END();
    
    Nifty Intraday Backtest.PNG
     
  5. Wysiwyg

    Wysiwyg Everyone wants money

    Posts:
    8,424
    Likes Received:
    260
    Joined:
    Aug 8, 2006
    Backtests are not what happens in real time. Anyway, dream on. :bad:
     
  6. Roller_1

    Roller_1

    Posts:
    304
    Likes Received:
    71
    Joined:
    Sep 13, 2013
    Why do the testing then?? Do it properly and it should be pretty close

    I'm not sure about intra day as i've never tested it.
     
  7. Wysiwyg

    Wysiwyg Everyone wants money

    Posts:
    8,424
    Likes Received:
    260
    Joined:
    Aug 8, 2006
    Testing reveals there are millions of dead ends. Keep looking though, the edge could be in the next test run.
     
  8. howardbandy

    howardbandy

    Posts:
    838
    Likes Received:
    102
    Joined:
    Jun 13, 2007
    Greetings --

    In the nerdy terminology of system development, having a profitable backtest is a necessary condition, but not a sufficient condition, to having profitable live trading.

    Trading systems are models -- sets of indicators, parameters, rules, and patterns -- that, together with price data indicate profitable trading opportunities. Developing the system is a process of tuning the model to the data, then testing to determine whether the relationships recognize profitable and persistent signals or just the randomness in the data.

    Validation using data that was not seen during the fitting process gives a better, but still not perfect, indication of the potential for profitable trading.

    Traditional trading system development platforms, such as AmiBroker, use the "decision tree" type of model. Decision trees are easy to build and easy to understand. One of their drawbacks is their sensitivity to data and tendency to overfit. In-sample results are often not even close to out-of-sample results. Hence the importance of validation before trading. Even before enthusiasm. "Properly" means "including rigorous validation."

    Best regards, Howard
     
    Dundee2 likes this.
  9. snehil2010

    snehil2010

    Posts:
    4
    Likes Received:
    0
    Joined:
    Sep 20, 2016
    I appreciate the positive criticism. But would not completely agree to the fact that "Backtests are not what happens in real time". Yes, positive backtest report is not the only criteria for successful systems, but definitely its one of the most important thing to look for. Positive backtesting with monte carlo analysis or walk forward analysis can lead to a very successful trading system.
     
  10. howardbandy

    howardbandy

    Posts:
    838
    Likes Received:
    102
    Joined:
    Jun 13, 2007
    Hitting the dead horse one more time ---

    A positive backtest report is Necessary, but is Not Sufficient. Once the backtest is shown to be positive, ignore it. It has no further value. Ignore whatever profit or loss or trade list or equity curve that resulted from it.

    In-sample (that it, backtest) results have No value in estimating future performance of a trading system. None. Independent validation using data that is more recent than the in-sample data and has not used (not even once) during model fitting begins to provide useful estimates of future performance.

    When properly used, walk forward is a very useful validation technique.

    Monte Carlo is a whole library of tools. Some are straight forward and easily used, others quite sophisticated and tricky. Used correctly, they can be very useful. Used naively or carelessly, they can be extremely misleading.

    There Will Be out-of-sample validation using data that is more recent than the in-sample data and that has not been used during model fitting. That happens at least one time for every system -- when the system leaves the development lab after the model fitting phase and begins live trading. If the developer has not performed rigorous validation, no worries -- the market will happily do it for a fee.

    The market. That is, on balance, the universe of systems developed (almost entirely) by large, well funded, well educated, well equipped scientists using sophisticated modeling techniques, and professional development and validation techniques.

    Best, Howard
     
  11. jsqd1

    jsqd1

    Posts:
    3
    Likes Received:
    0
    Joined:
    Jan 31, 2017
    I know I'm a tad late with this, but I agree with Howard.
    I develop my systems over say 2 year time frames that are a mix of good and bad. Study the results, tweak. Then backtest over say 15 years of woeful and wonderful. Then I run the backtest to end 3 months ago, pick up the open trades and papertrade and keep papertrading until I close all open positions. Then do some maths of performance, pluses and minuses.
    If good, I go live. If not so good, it's either back to the drawing board or start something new.
     
Loading...

Share This Page