Portfolio Trading (Trading with Multiple Stocks/Instruments) is the next big step in a traders life once he understand that he want to reduce the volatility in his trading strategy. And Amibroker comes handly when comes to portfolio back-testing. And this tutorial explains how to do portfolio back-testing step by step.
1) Create Watchlist in Amibroker. Watchlist is basically a list of stocks you would like to monitor or test. In this example i had added NIFTY-I and BANKNIFTY-I in the watchlist. You can add your own list of symbols you are willing to test
2)Goto New Analysis->Backtester Settings -> And Set the Periodicity of your choice. In my case i set as 5min
3)And Select the Apply to dropdown as Filter and Select the required watchlist in the Filter Settings.
4)Now add the Backtesting Template to your AFL code to the beginning of your trading system. Sample Back-testing template shown below. Which used to take 4 lots of Nifty and 2 lots of Bank Nifty every time. The Brokerage Commission amount has to be set as per your brokerage plan. Here in this example i had taken a per leg commissions (includes brokerage, taxes, slippages) of Rs150 for 4 lots of Nifty and Rs150 for 2 lots of Bank Nifty. And here i assumed per order brokerage for deciding the per leg commisision rates.
5)Set the Margin required in the template provided below as per your brokers margin.
6)Set the Maxopenposition as per the number of symbols you are willing to backtest. As Iam backtesting Nifty and Bank Nifty Futures in my case it is 2
7)goto Symbols->Information and set the Contract Specification as shown below
|Round Lot Size||25||25|
8)Now Press the Backtest Button to get the Backtesting report.