Hello zeek,

 

the j-loop is executed if your condition inside the i-loop is true.

 

A)    You could start your j loop also at the position of i. 
The value of i is already available, therefore it not necessary to start j
at the same position. However it's easier to initialize j with i if you
simply want to iterate through any amount of bars, including the current
bar. 



B)    i = j simply gives the value of j back to the main loop, so that the
i-loop can walk forward at the end of j-loop position.
It depends on your code whether you need it or not. For example you don't
need it if you simply want to calculate the average of the last 5 highs
whenever your "i-condition" is true.

 

 

 

Thomas

www.PatternExplorer.com

 

 

From: [email protected] [mailto:[email protected]] On Behalf
Of zeek ing
Sent: Monday, May 11, 2009 2:58 PM
To: [email protected]
Subject: [amibroker] looping question

 






Hello all 

I am trying to understand loops more clearly. I have a question on some code
that i  have been studying maybe someone can help:
If I have a loop


for( i = 0; i < BarCount; i++ ) 
{
  condition ..... 
    
    {


        for (j = i + 1; j < BarCount; j++) 
        {  ........      .....


                   i = j;
                break;
        }
}


I am trying to understand this loop construct.
a) why would i set J to i+1? why not have j=i?
b) what does i=j accomplish?? 


if anyone can clarify that would be great, I have seen this loop construct a
few times b4. 


thanks 
zeek 








Reply via email to