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

Re: [amibroker] For Loop Question



PureBytes Links

Trading Reference Links




Hello,
 
I noticed some more questions at the end:
 

<SPAN 
>1.  The previous old style error box 
that AB would display did not display; should it? Or is it 
gone?
<SPAN 
> 
<SPAN 
>No it is not gone, but you have created 
infinite loop.
<SPAN 
>AmiBroker has a infinite loop detection 
built-in but it requires
<SPAN 
>at least 100000 iterations to detect that 
loop is infinite so it may take a while.
<SPAN 
> 
<SPAN 
>2.  How do you increment a for loop 
with something other than 1?
<SPAN 
> 
<SPAN 
>Here is complete code. Note that I 
replaced Range++ by Range = Range + 5
<SPAN 
>in the 'iterator part' of for 
loop.
<SPAN 
> <FONT face=Tahoma 
color=black size=2>
<SPAN 
>Plot( Close, "Price", colorBlack, 
styleCandle );
<SPAN 
>for( Range = 15; Range <= 50; Range = 
Range + 5 )
<SPAN 
>   Plot( EMA( Close, Range ), 
"MA"+WriteVal(Range,0), colorRose + Range % 8, styleNoLabel 
);
<SPAN 
> 
<SPAN 
> 
<SPAN 
> 
<SPAN 
>3.  Without making me buy a C++ book, 
what are the properties of the "++" operator?
<SPAN 
>++ simply increments the variable by 
one.
<SPAN 
> 
<SPAN 
>X++;
<SPAN 
> 
<SPAN 
>is equivalent to 
<SPAN 
> 
<SPAN 
>X = X + 1;
<SPAN 
> 
<SPAN 
>(just less 
writing)
Best regards,Tomasz Janeczkoamibroker.com
<BLOCKQUOTE dir=ltr 
>
  ----- Original Message ----- 
  <DIV 
  >From: 
  Tomasz Janeczko 
  
  To: <A title=amibroker@xxxxxxxxxxxxxxx 
  href="">amibroker@xxxxxxxxxxxxxxx 
  Sent: Monday, April 14, 2003 12:12 
  PM
  Subject: Re: [amibroker] For Loop 
  Question
  
  Ken,
   
  The superiority of C-like syntax of for loop that AFL 
  uses
  over "basic-like" syntax is that it
  allows to iterate not only sequentialy but in any way you 
  like
  the 'iterator' part of the statement could be any 
  statement you like
   
  for example you can create for loop that generates power 
  sequence
  of 1, 2, 4, 8, 16, 32, 64, 128 as easy as:
   
  for( i = 1; i <= 128; i = 2 * i )
  {
   ... 
  }
   
  So, to answer your question the solution is very 
  simple:
   
  for( x = 1; x <= 20; i = i + 2 )
  {
     ... .do whatever you like
  }
   
   
  Best regards,Tomasz Janeczkoamibroker.com
  <BLOCKQUOTE 
  >
    ----- Original Message ----- 
    <DIV 
    >From: 
    Ken Close 

    To: <A title=amibroker@xxxxxxxxxxxxxxx 
    href="">AmiBroker List 
    Cc: <A title=bugs@xxxxxxxxxxxxx 
    href="">bugs@xxxxxxxxxxxxx 
    Sent: Monday, April 14, 2003 12:06 
    PM
    Subject: [amibroker] For Loop 
    Question
    
    
    <SPAN 
    >Question and Problem:
    <SPAN 
    > 
    <SPAN 
    >FOR/NEXT Loops in old Basic code had an increment 
    variable:
    <SPAN 
    > 
    <SPAN 
    >FOR(X=1,20,2) <<-- go from 1 to 20 
    incrementing by 2
    <SPAN 
    >NEXT X
    <SPAN 
    > 
    <SPAN 
    >The new FOR Loop says:
    <SPAN 
    >for( initializer_part; 
    conditional_expression; iterator_part ) statement;
    <SPAN 
    > 
    <SPAN 
    >So dumb me, wanting to try the code 
    example:
    <SPAN 
    > 
    <SPAN 
    >Plot( Close, "Price", colorBlack, 
    styleCandle );
    <SPAN 
    >for( Range = 15; Range < 100; 
    Range++ )
    <SPAN 
    >   Plot( EMA( Close, Range 
    ), "MA"+WriteVal(Range,0), colorRose + Range % 8, styleNoLabel 
    );
    <SPAN 
    > 
    <SPAN 
    >But wanting to make the EMA ribbons 
    further apart than just an increment of 1, changed the statement 
    to
    <SPAN 
    > 
    <SPAN 
    >For(Range=15; Range < 50, 5 
    )
    <SPAN 
    > 
    <SPAN 
    >And promptly locked up the 
    program.
    <SPAN 
    > 
    <SPAN 
    >Questions:
    <SPAN 
    >1.  The previous old style error 
    box that AB would display did not display; should it? Or is it 
    gone?
    <SPAN 
    >2.  How do you increment a for 
    loop with something other than 1?
    <SPAN 
    >3.  Without making me buy a C++ 
    book, what are the properties of the "++" operator?
    <SPAN 
    > 
    <SPAN 
    >KenSend 
    BUG REPORTS to bugs@xxxxxxxxxxxxxSend SUGGESTIONS to 
    suggest@xxxxxxxxxxxxx-----------------------------------------Post 
    AmiQuote-related messages ONLY to: amiquote@xxxxxxxxxxxxxxx (Web page: 
    <A 
    href="">http://groups.yahoo.com/group/amiquote/messages/)--------------------------------------------Check 
    group FAQ at: <A 
    href="">http://groups.yahoo.com/group/amibroker/files/groupfaq.html 
    Your use of Yahoo! Groups is subject to the <A 
    href="">Yahoo! Terms of Service. 
    






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.