Testing on multiple symbols with different commission rates

Dear community, this is my first post here.

I have a question that I cannot imagine nobody else has run into. Nevertheless I could not find it discussed in this forum before. Please tell me if I missed it.

The question is: is it possible to set different backtesting options, specifically the commission amount, for different symbols in the same backtest? (And if so, how?)

At the moment it seems to me you can use SetOption(CommissionAmount) only once in a system. Am I wrong, or is there another way?

Either define multiple-tiered commission table (where commission depends on value/price/n umber of shares or whatever else), or add commission directly to trade price
http://www.amibroker.com/guide/h_backtest.html (scroll to controlling trade price)

1 Like

Thank you very much for the quick response, Tomasz.

The trade price option makes sense to me. The commission table I think would not work as well for this, unless you can define for each symbol which tier to use regardless of value/price/number of shares. But I don't think you can... And even if you could, I would need more than five different commission rates.

Anyway, I think I should be able to work with option 2. So thank you for that!

Right. A little mystery came up in testing this.

I have, as an experiment, added a six cent spread to the entry price in this way for entries (adding to the buy price, subtracting from the short price). Now if I compare that with using a $0.06 commission per share in the regular way, I get a different result. Both outcomes are less than the results without commission, but not the same. What could possibly explain this? Should it not come down to the same thing?

Follow this: How to ask a good question and this How do I debug my formula? - post the code. The difference may be coming from many places, for example:

  • by adding 0.06 to price you may be exceeding High and AmiBroker won't allow that by default (use How do I debug my formula? to find out) - you would need to use SetOption() function to disable price bound checking
  • the same with sell side / subtracting from price / hitting the Low
  • your code may be using ApplyStops (then it is exiting at stop level and your code that adds to price is not used)
  • different prices may cause different trade sizes to be taken (if you are using position size based on % of equity)
  • you may have mistake in the formula

Anyway, your post needs to be way more precise not to cause guessing games How to ask a good question

Generally every change in formula and/or settings typically causes changes in the results. So the only way to find out is: How do I debug my formula?

1 Like

Thank you for contributing these possible solutions. I can rule out the first option, but yes, it seems to be the ApplyStop issue because of which the amount is applied only once.

I was in fact conscious of this, but I was assuming the $ per trade was also for a round trip, which it is not.

There still is a slight difference after this, but that is probably because of the different trade sizes, as I do indeed use % risk.

Thank you again for these suggestions!