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

[amibroker] How to get Report from Batch Backtest?



PureBytes Links

Trading Reference Links

Below is a really old message from 2 years ago that I wanted to revisit.

1) If I do AA.Backtest(0), how can I programmatically refer to the
Report that was just (automatically) generated? I saw that it goes
into the /Reports folder and is timestamped, but other than by
searching that whole directly to get the most recently modified
directory, is there any other way to know which report this Backtest
generated? What if I'm batch-running a bunch of backtests in rapid
succession? Is there a way the value of the report name could be
stored in a variable somewhere for us to access?

(My goal is to run AA from a webpage and display the HTML results back
in a browser window, if anyone else has done this already please let
me know)

2) I also noticed that the Report is only generated automatically if I
manually start Amibroker prior to running my batch script. If it's not
already running and I run my script, Windows somehow can find the
Broker.Application object and Backtest correctly, but the Report is
not automatically generated. This might be bug? I'm not a windows
programmer, so I'll admit to not knowing how the script references
that Broker.Application without it being already running.

3) I noticed all the current documentation still refers to
AA.Backtest() and not AA.Backtest(0), you might want to update the
automation scripts so they're more current. The "outdated" version
from 2002 is still the only one I saw available for reference.




Alan,

The code still works for me, but I wanted to point out that
the script performs "old" backtest.

If you are interested in PORTFOLIO backtest you have to
change
AA.Backtest();
to
AA.Backtest(0);

and
remove Report() call.

Best regards,
Tomasz Janeczko
amibroker.com
----- Original Message -----
From: "firehorse888uk" <firehorse888uk@xxx>
To: <amibroker@xxxxxxxxxxxxxxx>
Sent: Tuesday, June 01, 2004 11:42 PM
Subject: [amibroker] Re: Bug in batch testing?


Hi,

Thank you.

I just copied the code from the help file. I thought I would try a
example that 'works' rather than go from scratch.

Thanks for clarifying that.
--
Alan

--- In amibroker@xxxxxxxxxxxxxxx, "Tomasz Janeczko" <amibroker@xxxx>
wrote:
> Hello,
>
> The script you are using is obsolete.
>
> The script below was created Dec 22, 2002 for use with version 4.23
> which did not have portfolio backtester (only 'old backtester' was
present)
>
> Now the version is 4.56.1 and OLE interface has changed because
> it supports new portfolio backtesting. Reports in portfolio backtest
> are generated automatically without need to call "report" method at all.
>
> Best regards,
> Tomasz Janeczko
> amibroker.com
> ----- Original Message -----
> From: "firehorse888uk" <firehorse888uk@xxxx>
> To: <amibroker@xxxxxxxxxxxxxxx>
> Sent: Tuesday, June 01, 2004 4:10 PM
> Subject: [amibroker] Bug in batch testing?
>
>
> Hi,
>
> My test batch file is very simple.
>
> I've modified the example batch script very slightly.
>
> The program executes the backtest and then comes up with an error. No
> report is generated.
>
> Is this a bug?
> --
> Alan
> ==========================================================
> Buy= Cross(StochD(300,3,3),25);
> Sell=Cross(75,StochD(300,3,3));
> ===========================================================
> EnableScript("jscript");
> <%
> /*****************************
> *
> * BatchTest.js
> *
> * Batch testing sample script
> * Shows how to use JScript and new AmiBroker 4.23
> * 'Analysis' object to perform batch backtesting
> * and generate reports
> *
> * Created: Dec 21, 2002 TJ
> * Last modification: Dec 22, 2002 TJ
> *
> * Copyright (C)2002 Amibroker.com
> *
> * Status: Freeware
> * You can use/modify/adopt this code freely
> *
> */
>
> /* The directory where AFL files are stored
> ** Also reports generated by the bactest
> ** will be saved here
> */
>
> AFLFolder = "C:\\Documents and Settings\\Alan\\My
> Documents\\Finance\\Amibroker\\batchtest";
>
> var AB, AA;
> var fso, f, f1, fc, s;
> var filename;
>
> /* Create AmiBroker object and get Analysis object */
>
> AB = new ActiveXObject("Broker.Application");
> AA = AB.Analysis;
>
> /* backtest over symbols and all quotes*/
> AA.ClearFilters();
> /*AA.ApplyTo = 0; /* use symbols */
> /*AA.RangeMode = 0; /* all quotes */
>
> /* to use filters you should uncomment lines below */
>
> AA.ApplyTo = 2; /* use filters */
> AA.Filter(0,"watchlist") = 1 /* watch list number */;
> // AA.Filter(0,"group") = 0 /* group number */;
>
>
> /* Create FileSystemObject */
> fso = new ActiveXObject("Scripting.FileSystemObject");
>
> /* Iterate through all files in the folder */
> f = fso.GetFolder(AFLFolder);
> fc = new Enumerator(f.files);
> for (; !fc.atEnd(); fc.moveNext())
> {
> /* we need to add empty string to make sure that filename is a
> string object*/
> filename = "" + fc.item();
>
> /* check the AFL extension */
> if( filename.substr( filename.length - 4 ).toUpperCase() == ".AFL" )
> {
> if( AA.LoadFormula( filename ) )
> {
> AA.Backtest();
>
> reportname = filename.substr( 0, filename.length - 3 ) + "HTML" ;
>
> AA.Report( reportname ); /* generate report */
> }
> }
> }
>
> %>