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

[amibroker] Re: How do I get the value of one of the optimized columns?



PureBytes Links

Trading Reference Links

Ly,

You can get any of the included metrics after running a backtest. An 
optimization is just a collection of backtests. So, your code will be 
executed for each backtest in the optimization.

Copy the following script to a file (ending with .afl extension), 
load it into the AA window, set to run against active symbol, select 
any date range of 5 or more days, then click the Optimize button.

It will generate a file named "myfile.txt" in your Amibroker 
directory. The file will contain a single line for each optimization 
step. You'll need to rename or delete the file between optimizations, 
else the next optimization will continue to get appended to whatever 
is already in the file.

SetBacktestMode(backtestRegularRaw); 
SetCustomBacktestProc(""); 

trigger = Optimize("Trigger", 1, 1, 4, 1);

if (Status("action") == actionPortfolio) {
	bo = GetBacktesterObject();
	bo.PreProcess();

	for (bar = 0; bar < BarCount; bar++) {
		bo.ProcessTradeSignals(bar);
	}

	bo.PostProcess();

	stats = bo.getPerformanceStats(0);
	carMDD = stats.getValue("CAR/MDD");
	fh = fopen( "myfile.txt", "a"); 

	if (fh) { 
	   fputs("CAR/MDD: " + carMDD + "\n", fh); 
	   fclose(fh); 
	} 
}

Buy = DayOfWeek() == trigger;
Sell = DayOfWeek() == 5;

Refer to the links provided in my earlier response for more detail.

Mike

--- In amibroker@xxxxxxxxxxxxxxx, "loveyourenemynow" 
<loveyourenemynow@xxx> wrote:
>
> Hi Mike,
> 
> Are you sure you can get optimization result from custum backtester
> interface? Can you make an example? As far as I know there is such a
> feature from the backtesting interface, but there may be from OLE, 
and
> if you know it, please let me know.
> 
> Thanks
> 
> Ly
> --- In amibroker@xxxxxxxxxxxxxxx, "Mike" <sfclimbers@> wrote:
> >
> > Try looking in the user guide under advanced portfolio backtester 
> > interface, to see how to get at the stats information.
> > 
> > e.g.
> > http://www.amibroker.com/guide/a_custombacktest.html (bottom of 
page)
> > 
> > Then look at file operations fopen, fputs, fclose.
> > 
> > e.g.
> > http://www.amibroker.com/guide/afl/afl_view.php?id=227
> > 
> > Mike
> > 
> > --- In amibroker@xxxxxxxxxxxxxxx, "lou" <loulh@> wrote:
> > >
> > > After running an optimization I want to get the value from one 
of 
> > the columns in the report and be able to put it into a file for 
> > further reference.  (For example, the first value in the RAR 
column) 
> > Is there a way to do this?
> > > 
> > > lou
> > >
> >
>



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

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/