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

RE: [amibroker] Re: Help on automating optimization (genetic algorithms)



PureBytes Links

Trading Reference Links

Hello DT,

The procedure I suggested simply cascades inline optimization loops (one
stage only) as shown below, carrying forward optimized variables. I just
copied this code from my archive without verification but hopefully it
conveys the idea.

herman

// Inline optimization
bestequity = 0;
bestrange = 0;
// optimization loop
for( range = 10; range < 20; range ++ )
{
Buy = Cross( Close, EMA( Close, range ) );
Sell = Cross( EMA( Close, range ), Close );
LastEquity = LastValue( Equity() );
if( LastEquity > bestequity )
{
bestequity = LastEquity;
bestrange = range;
}
E=Equity(1);
AddColumn( BestRange, "R="+WriteVal(range,1.0));
AddColumn( BestEquity, "E="+WriteVal(range,1.0));
}
Range = BestRange;
Buy = Cross( Close, EMA( Close, range ) );
Sell = Cross( EMA( Close, range ), Close );
Filter = Status("LastBarInTest");
herman.

-----Original Message-----
From: DIMITRIS TSOKAKIS [mailto:TSOKAKIS@xxxxxxxxx]
Sent: November 13, 2003 4:56 PM
To: amibroker@xxxxxxxxxxxxxxx
Subject: [amibroker] Re: Help on automating optimization (genetic
algorithms)


Herman,
How did you do it ?
Because:
The
x=Optimize("x",10,10,50,10);b=Optimize("b",10,10,50,10);
Buy=Cross(StochD(x),b);
Sell=Cross(80,StochD(x));Short=Sell;Cover=Buy;
needs 25 steps.
The
x=Optimize("x",10,10,50,10);
for(b=10;b<=50;b=b+10)
{
Buy=Cross(StochD(x),b);
Sell=Cross(80,StochD(x));Short=Sell;Cover=Buy;
}
needs 5 steps, because the results will have *only* the last b=50
choice.
The
for(b=10;b<50;b=b+10)
{
x=Optimize("x",10,10,50,10);
Buy=Cross(StochD(x),b);
Sell=Cross(80,StochD(x));Short=Sell;Cover=Buy;
}
needs 625 [!!] steps and *does not* give the optimal solution.
Is it possible to give an example?
Dimitris Tsokakis
--- In amibroker@xxxxxxxxxxxxxxx, "Steve Dugas" <sjdugas@xxxx> wrote:
> Hi,
>
> True, unfortunately. A simple way to look at it is by counting the
number of
> combinations tested. For example, say I am optimizing on 2
variables, each
> with 10 steps. If I optimize them together, I am testing 10 x 10 or
100
> combinations. If I optimize them one at a time, I am testing 10 +
10 or 20
> combinatins. The second way will certainly be faster, because I am
only
> testing 20% of the possible combinations. The true optimal results
are
> likely to lie somewhere in the 80% of combinations that I have not
tested..
> The more variables used, the % of possible combinations actually
tested
> continues to drop. For 3 variables, 30/1000 or only 3%. For 4
variables,
> 40/10,000 or only 0.4 %, etc...
>
> Steve
>
> ----- Original Message -----
> From: "DIMITRIS TSOKAKIS" <TSOKAKIS@xxxx>
> To: <amibroker@xxxxxxxxxxxxxxx>
> Sent: Thursday, November 13, 2003 12:47 AM
> Subject: [amibroker] Re: Help on automating optimization (genetic
> algorithms)
>
>
> > Gary,
> > The procedure you describe does not make any sense.
> > In the simple example
> > x=Optimize("x",10,10,100,10);
> > b=Optimize("b",10,10,50,10);
> > s=Optimize("s",50,50,90,10);
> > Buy=Cross(StochD(x),b);
> > Sell=Cross(s,StochD(x));
> > the optimal solution is [30,20,80]
> > If I optimize first the x, ie
> > x=Optimize("x",10,10,100,10);
> > b=10;//Optimize("b",10,10,50,10);
> > s=50;//Optimize("s",50,50,90,10);
> > Buy=Cross(StochD(x),b);
> > Sell=Cross(s,StochD(x));
> > [optimal x=80]
> > then the b, ie
> > x=80;//Optimize("x",10,10,100,10);
> > b=Optimize("b",10,10,50,10);
> > s=50;//Optimize("s",50,50,90,10);
> > Buy=Cross(StochD(x),b);
> > Sell=Cross(s,StochD(x));
> > [optimal b=10]
> > and finally the s, ie
> > x=80;//Optimize("x",10,10,100,10);
> > b=10;//Optimize("b",10,10,50,10);
> > s=Optimize("s",50,50,90,10);
> > Buy=Cross(StochD(x),b);
> > Sell=Cross(s,StochD(x));
> > [optimal s=90]
> > I will have the [80,10,90] solution, which is far from the actual
> > optimal [30,20,80]
> > Unfortunately, the optimal[x,b,s] *is not* the optimal[optimal
[optimal
> > [x],b],s], consequently this procedure is wrong from the
beginning.
> > There is no chain rule for composite optimizations and you will
have
> > very few probabilities to find the optimal.
> > Another basic issue: You do not even have the
> > optimal[optimal[x],y] equal to optimal[optimal[y],x]
> > property, both will be far from the optimal[x,y] and you can not
even
> > interchange the priorities.
> >
> > Herman,
> > The results of cascade optimizations will not give the optimal
> > result, even if you save some time. As for this last property, I
do
> > not think you save any time, optimization is an internal loop, as
far
> > as I understand...
> > Dimitris Tsokakis
> >
> >
> > --- In amibroker@xxxxxxxxxxxxxxx, "Herman vandenBergen"
<psytek@xxxx>
> > wrote:
> > > You can optimize using for() loops and examples of this method
have
> > been
> > > posted on the list. This would allow you to optimize one
parameter
> > first in
> > > the first loop-optimization and then go on the the next loop-
> > optimization
> > > using the result of the first loop-optimization in your
> > calculations. This
> > > way you will save lots of time and you can optimize an unlimited
> > number of
> > > parameters without looking at billions of iterations.
> > >
> > > happy tinkering,
> > > herman.
> > >
> > >
> > >   -----Original Message-----
> > >   From: Gary A. Serkhoshian [mailto:serkhoshian777@x...]
> > >   Sent: November 13, 2003 7:00 AM
> > >   To: amibroker@xxxxxxxxxxxxxxx
> > >   Subject: [amibroker] Help on automating optimization (genetic
> > algorithms)
> > >
> > >
> > >   Hi all,
> > >
> > >   I should preface this e-mail by saying that I'm not trying to
> > create a
> > > Rube Goldberg as I can go through the process ourlined below
> > manually.  So,
> > > if what I'm suggesting requires a Rube Goldberg type solution
let
> > me know,
> > > and I'll let it go.
> > >
> > >   Essentially what I'm doing with optimizations over multiple
> > variables is
> > > prioritizing variables on importance, and optimizing one
variable
> > at a time
> > > leaving the others static.  I just keep iterating through all
the
> > variables
> > > until things stabilize in terms of standard measures.  The
cocktail
> > party
> > > term is genetic algorithms, but between us it's necesary as
> > optimizing over
> > > multiple variables (4+)  will either take too long or worse
cause
> > AmiBroker
> > > to crash due to memory issues.
> > >
> > >   Here's the punchline.  Can you all give some input on ways to
> > program this
> > > in afl so as to automate the process outlined above rather than
me
> > manually
> > > iterating through as it is labor intensive.
> > >
> > >   Many thanks,
> > >   Gary
> > >
> > >
> > > ----------------------------------------------------------------
----
> > --------
> > > --
> > >   Do you Yahoo!?
> > >   Protect your identity with Yahoo! Mail AddressGuard
> > >   Send BUG REPORTS to bugs@xxxx
> > >   Send SUGGESTIONS to suggest@xxxx
> > >   -----------------------------------------
> > >   Post AmiQuote-related messages ONLY to:
amiquote@xxxxxxxxxxxxxxx
> > >   (Web page: http://groups.yahoo.com/group/amiquote/messages/)
> > >   --------------------------------------------
> > >   Check group FAQ at:
> > > http://groups.yahoo.com/group/amibroker/files/groupfaq.html
> > >
> > >   Your use of Yahoo! Groups is subject to the Yahoo! Terms of
> > Service.
> >
> >
> >
> > Send BUG REPORTS to bugs@xxxx
> > Send SUGGESTIONS to suggest@xxxx
> > -----------------------------------------
> > Post AmiQuote-related messages ONLY to: amiquote@xxxxxxxxxxxxxxx
> > (Web page: http://groups.yahoo.com/group/amiquote/messages/)
> > --------------------------------------------
> > Check group FAQ at:
> http://groups.yahoo.com/group/amibroker/files/groupfaq.html
> >
> > Your use of Yahoo! Groups is subject to
http://docs.yahoo.com/info/terms/
> >
> >


Yahoo! Groups Sponsor
ADVERTISEMENT




Send BUG REPORTS to bugs@xxxxxxxxxxxxx
Send SUGGESTIONS to suggest@xxxxxxxxxxxxx
-----------------------------------------
Post AmiQuote-related messages ONLY to: amiquote@xxxxxxxxxxxxxxx
(Web page: http://groups.yahoo.com/group/amiquote/messages/)
--------------------------------------------
Check group FAQ at:
http://groups.yahoo.com/group/amibroker/files/groupfaq.html

Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.



------------------------ Yahoo! Groups Sponsor ---------------------~-->
Buy Ink Cartridges or Refill Kits for your HP, Epson, Canon or Lexmark
Printer at MyInks.com. Free s/h on orders $50 or more to the US & Canada.
http://www.c1tracking.com/l.asp?cid=5511
http://us.click.yahoo.com/mOAaAA/3exGAA/qnsNAA/GHeqlB/TM
---------------------------------------------------------------------~->

Send BUG REPORTS to bugs@xxxxxxxxxxxxx
Send SUGGESTIONS to suggest@xxxxxxxxxxxxx
-----------------------------------------
Post AmiQuote-related messages ONLY to: amiquote@xxxxxxxxxxxxxxx 
(Web page: http://groups.yahoo.com/group/amiquote/messages/)
--------------------------------------------
Check group FAQ at: http://groups.yahoo.com/group/amibroker/files/groupfaq.html 

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