EOD Backtesting help needed

Hello Experts,
I do my analysis based on EOD data & basis my EOD analysis I take positions next day. Whether I need to initiate a new position (Buy or Short) or I need to close my existing position (Sell or Cover) I use the same methodology. I have built a trading system & it is giving me great results on scan basis however, I want to backtest this strategy with proper rules.

Can someone help me with the backtest settings in Amibroker for EOD analysis? Here are some details -

  1. My capital is 20 lakhs
  2. I can take 2% risk on my deployed capital in each trade as max stop loss
  3. I plan to keep only 1 position at a time (will increase quantity)
  4. For buy trigger I want to buy only if previous day high is broken. Similarly for short positions, I want to initiate a short if previous day low is broken

I am new to this so your help will be really helpful. I am happy to share few trading systems post backtest if the results are good. I am sure this will help a lot of people.

Thanks in advance.

Regards
Vihaan

A good place to start would be here
https://www.amibroker.com/guide/h_backtest.html

For this you use the Analysis window.

If you scroll down to about half way, you can see screen shots of the backtester settings.
You can set periodicity to "Daily"
#1 your capital is in the field "initial equity"
#2 your Stop Loss / targets can be defined under the 3rd tab called "Stops"
#3 Max open positions can be defined in 5th tab under "Portfolio"
#4 Entry / Exit rules defined in the AFL file

AB is an advanced tool, and it has a very detailed KB and guide.
The only way you can get around is by reading / learning and testing.
These stages cannot be done by hand-holding and i'm sure you get the point.

also, you would like to check some guidelines here:

3 Likes

Yours kindly @amibrofan ,

To begin with, this section of the User Guide Back-testing your trading ideas contains the fundamentals and from here you should be able to construct the settings as per your requirements.

Then there are numerous KB (Knowledge Base) articles on the subject. Let me Google it for you - click here.

You can also search this forum too (link), or visit the "AFL Programming" > "backtest" tag to read some discussions and exchange of ideas that must help you in the long run.

To add, the internet is filled with books, websites, courses on this subject - all waiting for you to discover!

Thank you

P.S. A bit off-topic, however essential! Are you aware of the "help vampire" phenomenon? Please read along.

3 Likes

@Cougar, the "Help Vampires" link is hysterical, although I'm laughing through my tears because it's so true! Thanks for the levity.

1 Like

@ghanson,

Neither was I aware of such a term earlier. The credit of introducing it goes to the Founder:

Forgot about it in due course of time, however until recently, as usual, fxshrat made me remember:

Sorry, I did not know how to give credits while writing it earlier. Glad you posted! :sweat_smile:

1 Like

Thank you Travick for your prompt response. Much appreciated!
These tricks have really helped me & I was able to backtest my trading idea perfectly.

I am doing individual stock backtesting (not in portfolio mode with multiple stocks) & the only problem I am facing is that signals are not coming proper. Ideally after every Long, I should get a Sell signal to close my position and after every Short I should get a Cover signal to close my position but I am getting distorted signals. I only see Long & Short signals and dont see Sell and Cover. Can you help? Thanks in advance.

image

You have not read carefully the posts on How To. If you want help, you need to provide ALL details including code and Backtester settings.
People here are unable to read minds and remote computers yet.

Thank you so very much Cougar for your kind response to help me out here. I sincerely appreciate it. Based on your help I was able to backtest my idea & it worked well. The only issue I face is that I am getting continuous Long or Short signals rather than coming one after other to square off open position. Any guidance to overcome this challenge would be highly appreciated. thanks a ton in advance.

Hello Cougar,

Not sure what have you posted but thanks for your response. I appreciate your help and guidance.

Let me see if I understand your doubt:

Every line in the report has data about a full operation (compounded of two "actions": BUY and the corresponding SELL, or SHORT and the corresponding COVER):

  • The first column is the operation type: "Long", for BUY/SELL operation, and "Short" for SHORT/COVER.
  • Columns 2, 3 (Date, Price): Shows the date and price for BUY or SHORT.
  • Columns 4, 5 (Ex. Date, Ex. Price): Shows the date and price for SELL or COVER

Is this the explanation you were looking for?

2 Likes

Thank you so much LeoCV for your help. Yes I overlooked the results & I thought one line has only 1 result whereas it was a complete trade (Buy/Sell, Short/Cover). No further questions on this.

Much appreciated!