A short tutorial (YouTube video) by Adrian Reid explaining how to export the equity curve produced by an AmiBroker system backtest into a CSV/Excel spreadsheet for separate analysis. Key steps: run the backtest; locate the generated equity symbol (ticker named "equity" shown as ~~~); load/select the provided AFL script named "Export System Equity Curve to CSV.afl"; run an Explore on the current symbol with Range = All quotes to produce columns (symbol, date, portfolio equity, cash, drawdown); select all rows (Ctrl‑A), copy (Ctrl‑C) and paste (Ctrl‑V) into Excel. The exported table reports daily portfolio equity, cash and drawdown for the backtest date range (example: from Jan 1993 to present in the demo).
Chapters
In this video, I'm going to explain to you how you can export your equity curve from a system backtest into a CSV file or into Excel so that you can analyze it separately in Excel. Amibroker does lots of things really well, but there's certain types of analysis that you might want to do in your backtesting on the equity curve that you just can't do in amibroker. And you need to put the data into a spreadsheet so that you can do the analysis in a more flexible way. So the first step that you're going to do in order to export your equity curve from a backtest is run the backtest and you can use all of the normal settings that you use for running backtest as normal. So you'll see here in the formula bar, I've just backtested a system called Adrian System and my from to date I've set from January 1993 to basically today. And I've applied it to a certain group of stocks. I've applied it in this case to the Australian Stock Exchange and the Hong Kong Stock Exchange. So we've run that backtest and as usual, you can click on the reports button here and get the report for the backtest. But what we really want to do now is look at the equity curve in Excel. So the first thing to understand is that when amibroker runs a backtest, it produces a new symbol or a ticker called equity, and it's actually called tilde, tilde, tilde. So in the symbols pane here, if you just type tilde, tilde, tilde, you'll see down here that.
The symbol called equity has come up as the filter option. So that contains all of the data that we want to export into Excel. Now what we're going to do is I've created a formula which allows us to explore that ticker code, that equity ticker code, and report back the daily equity, the cash balance and the level of drawdown that is occurring in that system in that equity curve day by day by day. Now, that file is contained on this webpage and it's called Export System Equity Curve to CSV afl, Very creatively named. And what that does is it looks into the equity stock ticker and pulls out the day by day.
Equity balance. It pulls out the cash that you're holding and it calculates the drawdown for each day in the backtest. So what we want to do now is run an exploration using this formula. Formula. So the first thing we're going to do is We've selected export system equity curve to AFL in the formula bar. Then in the range, we can just select all quotes because we want every bit of data that's in that equity stock ticker. And when we say apply to, we don't want to apply it to filter, because that's going to apply it to all of the stocks that we ran the backtest on. We want to apply it to current symbol. And because we've clicked on this symbol here, that's the current symbol. And what we're going to do is hit explore and you'll see that very quickly we get a number of columns here, five columns. The first one is the ticket name, which is always equity. The second one is the date, and then it calculates portfolio equity, the cash and the drawdown. Now, there's no data in the first few rows because I started my backtest in 93, but if you scroll down here, you'll see that each day we get the portfolio equity, the cash and the drawdown. And that data is reported every single day all the way to the present. So how do we get that into Excel? Pretty simple. Click on one of the rows, press Control A on your keyboard to highlight all rows, and then Control C on your keyboard to copy. Then you can go right across into Excel and I'll just find a new sheet here. And you can do click in the top left and Ctrl V to paste. And there, very simply, you have.
A table of all of the daily equity cash and drawdown from your backtest. So you can do all sorts of cool stuff in Excel using this. I'll leave it up to your imagination. And that's all for this video, so I hope that was helpful. See you in the next one. Bye for now.