Simulating a Portfolio of Strategies in Amibroker (1/2)

An important element in my vision on running my personal trading business is to diversify across multiple strategies. So far I have been focusing on development, running, automating  & monitoring individual trading strategies however I am turning my attention now to simulating the effect of running several strategies next to another.

As I am using Amibroker as the workhorse for my analyses, I have been focusing on trying to use Amibroker to simulate running multiple strategies. In this series of posts I am going to introduce a way of working to this. Admittedly,  the method has flaws and does not do the job 100% perfect, however it works for me.

I will start of with explaining the concept. After this introduction I will explain some of the key elements (including code). I will then demonstrate the application by simulating a portfolio of the three strategies that are described in this blog (here). Finally I will make comments on the flaws in this method.

From studying the various resources (Amibroker KB,, Howard Bandy’s books) I came to the conclusion that there are 2 fundamental different ways to simulate multiple strategies:
A) combine all strategies in one meta-strategy or
B) take a 2 step approach: run individual strategies first followed by a second (meta) strategy trading the outcomes of step 1

After some experiments I came to the conclusion that both options do not deliver the 100% solution. E.g. option A becomes complicated very quickly when trying to take a position for 2 strategies in the same instrument). Option B,  after running step does not allow you to simply analyse the individual trades of the underlying systems.  In the end I have chosen to work with option B. The main reason for this is that option B allows me to simulate various systems without complications. The cost we pay for it is that not all performance metrics are not easily available at meta-strategy level.

The main concept that I use can therefore me summarised as follows:

1. Run individual strategy in Backtester
2. Use custom backtest logic to generate individual strategy Equity curve
3. Repeat 1&2 for all systems of interest
4. Add individual equity curves to watchlist
5. Run meta-strategy in Backtester on watchlist

I am beyond my wordcount of 300 and have still a lot to write, so will create a second post with the further explaination, code, example and comments.

– QD –

10 thoughts on “Simulating a Portfolio of Strategies in Amibroker (1/2)

  1. I may not understand what you are trying to do here, but combining strategies is done very easily by generating teh equity curves in AB by running backtests and creating the composites for each equity curve.
    And next, running a formula which combines the curves with the weights you assigned for each strategy in your equity allocation into one final composite. And this gives you a very good idea how it would work in practice. Adn takes about 10 mins to write and run. Am I missing something?

  2. hi QD, great blog and thoughts. Looking forward to how you combine the many strategies into one.

  3. Option #3
    1) Run all strategies individually in AmiBroker as described.
    2) Export strategy-specific performance data to Excel
    3) Analyze performance of portfolio of strategies in Excel

    • Hi Ben,
      Yes this could be a nice alternative in case we want a more detailed analysis of underlaying performance characteristics (e.g. at individual trade level). I see some complexities in Excel coding (to keep things automated) the following example: suppose we run 5 strategies out of x and we switch to different 5 strategies every 3 months. How do we create the subset of trades from x imported strategies in excel. Yes I can see how to do this manually, however I want to do repeated analysis we need to automate.
      Another alternative could be to work with ready made software (e.g. MSA Analyser from Adaptrade)

  4. This is one of the reasons why I switched from AmiBroker (only used it briefly) to Trading Blox, which allows you to run multiple strategies as part of a “suite” of systems.
    This is closer to real-life trading and the implementation of running multiple systems together, with required reporting is very straight-forward.
    It also allows you to implement additional “meta-logic” at suite level giving you access to all systems at once (ie limit your risk on one instrument across the whole set of systems, the equity available for each system is updated/rebalanced based on the current P&L of all systems, etc.).

    It is quite a steep upgrade price-wise though…

    • Hi Jez.
      I have seen Tradingblox in the web, and I have thought in it as an alternative to Amibroker, but.. Does Tradingblox let backtests with multi-stocks systems and mix many systems also?
      And, is it as quick as Amibroker when mixing several multistocks-systems?
      Because I suppose that should be a complex matter to any software..


      • TB does allow for multi-system, multi-instrument testing, yes. And it runs pretty fast too (haven’t done any speed comparison testing but it feels the same order of magnitude as AmiBroker)

  5. Hi QD,

    Great stuff, am waiting for 2nd part.

    This is the most important feature (by far) that I feel is missing from Amibroker. There are so many comments on the wishlist regarding it, I don’t know why Tomasz keeps it on hold since 2006 already. 🙁


Leave a Comment