Backtesting in Amibroker .... Need to understand how to set it correctly

mastermind007

Well-Known Member
#1
Hello

Recently I decided to backtest a trading system that I have with me for over a year now and most of the trade that the system indicates on screen have been good.

So, modified AFL and added code to set predefined variables such as Buy, Sell, BuyPrice, SellPrice etc etc into the AFL.

Next, when backtesting was run, it took Buys on the date as indicated with Buy variable (coincides with arrows on screen) but it often rejects BuyPrice and shows bought at some other price.

In case of Sell, it gets worse. My UI is showing exit at 27 Jul 2012 whereas BT exited on 23 July 2012. I've verified that my Sell variable was not set on 23rd but was set on 27th.

Prices had dipped on 23rd but my SL (as defined into SellPrice) was not hit. I cannot even figure out where it got Sell Price from. It is not what I've set in Sell Price Array. Actual Price on back test report is at least 10 points below the Low and 7 points above where I had SL on that day.

Settings of back testing allow me to pick prices from dropdown but my prices are not any of those 5 listed.
 

ocil

Well-Known Member
#2
Hello

Recently I decided to backtest a trading system that I have with me for over a year now and most of the trade that the system indicates on screen have been good.

So, modified AFL and added code to set predefined variables such as Buy, Sell, BuyPrice, SellPrice etc etc into the AFL.

Next, when backtesting was run, it took Buys on the date as indicated with Buy variable (coincides with arrows on screen) but it often rejects BuyPrice and shows bought at some other price.

In case of Sell, it gets worse. My UI is showing exit at 27 Jul 2012 whereas BT exited on 23 July 2012. I've verified that my Sell variable was not set on 23rd but was set on 27th.

Prices had dipped on 23rd but my SL (as defined into SellPrice) was not hit. I cannot even figure out where it got Sell Price from. It is not what I've set in Sell Price Array. Actual Price on back test report is at least 10 points below the Low and 7 points above where I had SL on that day.

Settings of back testing allow me to pick prices from dropdown but my prices are not any of those 5 listed.
Make sure you are using the correct time frame when you do BT.
 

trash

Well-Known Member
#3
Hello

Recently I decided to backtest a trading system that I have with me for over a year now and most of the trade that the system indicates on screen have been good.

So, modified AFL and added code to set predefined variables such as Buy, Sell, BuyPrice, SellPrice etc etc into the AFL.

Next, when backtesting was run, it took Buys on the date as indicated with Buy variable (coincides with arrows on screen) but it often rejects BuyPrice and shows bought at some other price.

In case of Sell, it gets worse. My UI is showing exit at 27 Jul 2012 whereas BT exited on 23 July 2012. I've verified that my Sell variable was not set on 23rd but was set on 27th.

Prices had dipped on 23rd but my SL (as defined into SellPrice) was not hit. I cannot even figure out where it got Sell Price from. It is not what I've set in Sell Price Array. Actual Price on back test report is at least 10 points below the Low and 7 points above where I had SL on that day.

Settings of back testing allow me to pick prices from dropdown but my prices are not any of those 5 listed.
Create a simple sample code that duplicates your output. Make all your backtest settings and then save it as project file (*.apx) and upload it. Upload a short history file of the symbol you are using. Or send it to support (I'm not AB, just saying). Looks like a high probable user error. But makes no sense to guess without knowing more detail.
 

mastermind007

Well-Known Member
#4
Issue resolved! Following had happened.

Like most AFLs this too had many parameters that I had tweaked. This AFL had default SL% set at X and I had moved to Y.

UI was plotting according to manually set param whereas Back tester was using the default so all this phantom exits were showing up. Buy prices were next day open which was another setting.

When I ran on all nifty scrips, errors were far too many and nearly impossible to find. I ran it for one scrip only in very narrow time frame, while helped find the cause.
 

bharatk8

Active Member
#5
Dear Trash,

Saw results of your backtesting AFL in this forum giving profit/loss in % terms after exploration in spreadsheet like format.

I need it.I am ready to pay.I do not want your strategy.You may PM me.

Create a simple sample code that duplicates your output. Make all your backtest settings and then save it as project file (*.apx) and upload it. Upload a short history file of the symbol you are using. Or send it to support (I'm not AB, just saying). Looks like a high probable user error. But makes no sense to guess without knowing more detail.
 
Last edited:

mastermind007

Well-Known Member
#6
Dear Trash,

Saw results of your backtesting AFL in this forum giving profit/loss in % terms after exploration in spreadsheet like format.

I need it.I am ready to pay.I do not want your strategy.You may PM me.
Dear bharatk8

The LUA code that you sent me is very simple and freely available in MT4. Why do you want to redevelop what is already there? All you need to do is change colors! I've sent you emails
 
Last edited:

bharatk8

Active Member
#7
Dear mastermind007,

I have asked Mr.Trash for AFL.However if there is MT4 code for same purpose,I am interested in that too.

Thanks for pointing out that MT4 code is already there on net.
Dear bharatk8

The LUA code that you sent me is very simple and freely available in MT4. Why do you want to redevelop what is already there. All you need to do is change colors.
 

Similar threads

Trade in Rs 20, No more % brokerage

Name:Phone:
Email:City:
State:
Are you a day trader?