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

Re: [amibroker] For loop not understood



PureBytes Links

Trading Reference Links

Hi William,

Kind of hard to be more specific without more specifics   : - )   but for
one thing, your code is not testing all the combinations you probably want
to test. You need to use 2 nested loops. I assume you are trying to test 10
x 10 = 100 combinations, but in your code, both variables get incremented
with each pass, so:

1st pass   aa=1   bb=1
2nd pass  aa=2   bb=3
3rd pass  aa=3   bb=5...
will result in only 9 passes (9 combos tested) until it stops because aa is
no longer < 10

I think you want something like this:

For( aa=1; aa<=10; ++aa )
    For( bb=1; bb<=20; bb=bb+2 )  // test all ODD values of bb
    {
        Buy condition;
        Sell condition;
    }

This will test all values of bb while aa=1, then all values of bb while
aa=2, etc...



----- Original Message -----
From: "willem1940" <w.j.a.struyck@xxxxxxxxxxxxxx>
To: <amibroker@xxxxxxxxxxxxxxx>
Sent: Sunday, June 22, 2003 10:18 AM
Subject: [amibroker] For loop not understood


> Tradionally I would optimize  the 2 parameters Aa and Bb and got the
> best combination in terms of net profit after optimalisation. See
> below (simplified):
>
> Aa=4;
> Bb=9;
> Aa=optimize("aa",aa,1,10,1);
> Bb=optimize("bb",bb,1,20,2);
>
> Cc=function(aa,bb);
>
> Buy=cross(c,cc);
> Sell=cross(cc,c);
>
> Being a newbie in working with loops I made an attempt to put the
> above in a loop but the outcome is not in line with the tradional
> optimalisation; it is worse. It seems first to optimize Aa and
> subsequently Bb.
> Aa=0;
> Bb=0;
>
> For(aa=1,bb=1;aa<10;aa=aa+1,bb=bb+2)
> {
> Buy condition;
> Sell condition;
> }
>
> How do I correct this?
>
> Thanks.
>
> Willem Jan
>
>
>
>
> 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/
>
>



------------------------ Yahoo! Groups Sponsor ---------------------~-->
Get A Free Psychic Reading! Your Online Answer To Life's Important Questions.
http://us.click.yahoo.com/Lj3uPC/Me7FAA/ySSFAA/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/