Add benchmark equity curve to the strategy equity curve

Is there an option to automatically plot the benchmark equity curve in the same graph of the strategy equity curve?

Thanks

Heisenberg as in BB :wink: ? If so Jesse says that you could do so by adding SetForeign("BenchmarkSymbol") and Equity/Plot function calls to Portfolio Equity code in "Report Charts" folder.

1 Like

Yes as in BB , but also because i have a big respect and admiration for physicists.
They do the most beautiful job in the world :blush:

How i can access the equityline of the benchmark? Amibroker calculate it for sure because in report we can see all its statistics: cagr, maxdrawdown, etc.

If i just plot time serie of the benchmark symbol it have a different scale with respect to the equity of the strategy.

Thank you

So to conlcude, does not exist a quick way to plot (in the same chart) strategies equity and benchmark's equity? Yes i know, it could be done in excel very quickly exporting the equities curve of both. It's just to know if does exists a simpler and known way in Amibroker.
Thank you

Add this below one at the end of "1.0 Portfolio Equity" AFL of "Report Charts" folder of "Charts" window.
It comes close but not exactly the same end result as of "Statistics" page of BT report.

BenchmarkSymbol = "^GSPC";
SetForeign( BenchmarkSymbol, 1, True );
    // Disable trade delays
    SetTradeDelays( 0, 0, 0, 0 );
    // 100% invested
    SetPositionSize(100, spsPercentOfEquity);

    BuyPrice = Close;
    SellPrice = Close;

    Buy = Status( "firstbarintest" );
    Sell = Status( "lastbarintest" );
    Short = Cover = 0;

    // Disable stops
    ApplyStop( 0, 0, 0, 0 );
    ApplyStop( 1, 0, 0, 0 );
    ApplyStop( 2, 0, 0, 0 );
    ApplyStop( 3, 0, 0, 0 );
    // Get single security equity of analysis range
    eq = Equity(0, -1);
RestorePriceArrays();

Plot( eq, "Buy&Hold", colorBlueGrey );

14

8 Likes

Note that the formula above gives incorrect result (i.e. different result than portfolio backtester B&H) if you use it for security that has currency set to something different than BASE currency. It will give you result in that DIFFERENT currency, not in BASE currency. On the other hand, backtest report will report BASE currency profits.
This is because old backtester Equity() does not handle multiple currencies.

2 Likes

What about adding data of B+H Equity to one of the remaining (unused) data fields of ~~~EQUITY (e.g. one of the Aux fields)? I mean as a feature of some upcoming AmiBroker update. Or is it bad idea?

2 Likes

Yes it is planned and going to be implemented soon.

5 Likes

@fxshrat thanks this is very helpful. Similarly, how do we show the graph of drawdown of the portfolio in comparison to the benchmark on one chart?