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

RE: [amibroker] optimization code



PureBytes Links

Trading Reference Links

>From the release notes (in AmiBroker directory):

USAGE NOTES:

Optimization

Optimization in back tester is supported via new function called optimize.
The syntax of this function is as follows:

variable = optimize( "Description", default, min, max, step );

where:

variable - is normal AFL variable that gets assigned the value returned by
optimize function.
With normal backtesting, scanning, exploration and commentary modes the
optimize function returns default value, so the above function call is
equivalent to: variable = default;

In optimization mode optimize function returns successive values from min to
max (inclusively) with step stepping.

"Description" is a string that is used to identify the optimization variable
and is displayed as a column name in the optimization result list.

default is a default value that optimize function returns in exploration,
indicator, commentary, scan and normal back test modes

min is a minimum value of the variable being optimized

max is a maximum value of the variable being optimized

step is an interval used for increasing the value from min to max

Notes:

AmiBroker supports up to 10 calls to optimize function (therefore up to 10
optimization variables)
Each call to optimize generate (max - min)/step optimization loops and
multiple calls to optimize multiply the number of runs needed. For example
optimizing two parameters using 10 steps will require 10*10 = 100
optimization loops.
Call optimize function only ONCE per variable at the beginning of your
formula as each call generates a new optimization loops
Multiple-symbol optimization is fully supported by AmiBroker
Examples:

1. Single variable optimization:

sigavg = optimize( "Signal average", 9, 2, 20, 1 );

buy = cross( macd( 12, 26 ), signal( 12, 26, sigavg ) );
sell = cross( signal( 12, 26, sigavg ), macd( 12, 26 ) );

2. Multiple (3) variable optimization:

mfast = optimize( "MACD Fast", 12, 8, 16, 1 );
mslow = optimize("MACD Slow", 26, 17, 30, 1 );
sigavg = optimize( "Signal average", 9, 2, 20, 1 );





buy = cross( macd( mfast, mslow ) , signal( mfast, mslow, sigavg ) );
sell = cross( signal( mfast, mslow, sigavg ), macd( mfast, mslow ) );




After entering the formula just click on "Optimize" button in "Automatic
Analysis" window. AmiBroker will start testing all possible combinations of
optimization variables and report the results in the list. After
optimization is done the list of result is presented sorted by the Net %
profit. As you can sort the results by any column in the result list it is
easy to get the optimal values of parameters for the lowest drawdown, lowest
number of trades, largest profit factor, lowest market exposure and highest
risk adjusted annual % return. The last columns of result list present the
values of optimization variables for given test.


When you decide which combination of parameters suits your needs the best
all you need to do is to replace the default values in optimize function
calls with the optimal values. At current stage you need to type them by
hand in the formula edit window (the second parameter of optimize function
call).


-----Original Message-----
From: nkishor@xxxx [mailto:nkishor@x...]
Sent: Tuesday, August 21, 2001 4:11 PM
To: amibroker@xxxxxxxxxxxxxxx
Subject: [amibroker] optimization code


Can someone please post an example code
needed to call optimization. I don't know
how to work this new feature.

nand






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