[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[amibroker] Re: Output Equity Curve as Delimited File (e.g. CSV)



PureBytes Links

Trading Reference Links

Not sure if this is what you are looking for but this is how I get 
the equity curve into a csv file that I then use in Excel.

First you need to add the equity curve to your chart. Then right 
click on it and select "Edit Formula". Then add the following code to 
the botttom. 


h = fopen("c:\\temp\\portfolio.csv","w");
y = Year(); 
m = Month(); 
d = Day(); 
for( i = 0; i < BarCount; i++ ) 
{
    ds = StrFormat("%02.0f-%02.0f-%02.0f,", 
                     y[ i ], m[ i ], d[ i ] ); 
	if (eq[i] > -1000000)
	{
        fputs( ds, fh );
	ds = StrFormat("%02.2f,",  eq[i]); 
	fputs( ds, fh ); 
	ds = StrFormat("%02.2f\n",  Cash[i]); 
	fputs( ds, fh ); 
	}
}
fclose(fh);

You can change the name of the file and location. One thing to know 
is that the symbol that is shown must have data over the entire time 
of your backtest. The data file will be written whenever a new equity 
curve is generated by AB.

Hope this helps,
Cey

--- In amibroker@xxxxxxxxxxxxxxx, "Graham Johnson" <grahamj@xxx> 
wrote:
>
> I've looked through this forum and seen suggestions such as adding 
a 
> custom metric to the AA and then exporting the resultant file.  
This 
> would seem to require a deal of data massaging due to multiple 
report 
> entries for a given day, and also many trading days when there are 
no 
> report entries due to there not being a Buy or Sell.
> 
> The discussion on using FPUTS seems to be a good solution - but 
that 
> would be so much easier if one could traverse ~~~EQUITY (or any atc 
> symbol) and use FPUTS to write Date and Value.
> 
> Is that achievable, or am I asking too much?
> 
> Thanks
> 
> Graham
>



------------------------------------

Please note that this group is for discussion between users only.

To get support from AmiBroker please send an e-mail directly to 
SUPPORT {at} amibroker.com

For NEW RELEASE ANNOUNCEMENTS and other news always check DEVLOG:
http://www.amibroker.com/devlog/

For other support material please check also:
http://www.amibroker.com/support.html
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/amibroker/

<*> Your email settings:
    Individual Email | Traditional

<*> To change settings online go to:
    http://groups.yahoo.com/group/amibroker/join
    (Yahoo! ID required)

<*> To change settings via email:
    mailto:amibroker-digest@xxxxxxxxxxxxxxx 
    mailto:amibroker-fullfeatured@xxxxxxxxxxxxxxx

<*> To unsubscribe from this group, send an email to:
    amibroker-unsubscribe@xxxxxxxxxxxxxxx

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/