# Amibroker Trading System Collection with Backtest Report



## snehil2010 (20 December 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


----------



## jjbinks (20 December 2016)

These are just pdfs of pages from this website: http://tradingtuitions.com/


----------



## snehil2010 (20 December 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. 


```
//------------------------------------------------------
//
//  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:


----------



## snehil2010 (21 December 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.


```
//------------------------------------------------------
//
//  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();
```


----------



## Wysiwyg (21 December 2016)

snehil2010 said:


> 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.



Backtests are not what happens in real time. Anyway, dream on. :bad:


----------



## Roller_1 (21 December 2016)

Wysiwyg said:


> Backtests are not what happens in real time. Anyway, dream on. :bad:




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.


----------



## Wysiwyg (21 December 2016)

Roller_1 said:


> 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.



Testing reveals there are millions of dead ends. Keep looking though, the edge could be in the next test run.


----------



## howardbandy (22 December 2016)

Roller_1 said:


> 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.




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


----------



## snehil2010 (22 December 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.


----------



## howardbandy (22 December 2016)

snehil2010 said:


> 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.




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


----------



## jsqd1 (21 February 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.


----------

