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

RE: [amibroker] looping question



PureBytes Links

Trading Reference Links



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: amibroker@xxxxxxxxxxxxxxx [mailto:amibroker@xxxxxxxxxxxxxxx] On Behalf Of zeek ing
Sent: Monday, May 11, 2009 2:58 PM
To: amibroker@xxxxxxxxxxxxxxx
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






__._,_.___


**** IMPORTANT PLEASE READ ****
This group is for the discussion between users only.
This is *NOT* technical support channel.

TO GET TECHNICAL SUPPORT send an e-mail directly to
SUPPORT {at} amibroker.com

TO SUBMIT SUGGESTIONS please use FEEDBACK CENTER at
http://www.amibroker.com/feedback/
(submissions sent via other channels won't be considered)

For NEW RELEASE ANNOUNCEMENTS and other news always check DEVLOG:
http://www.amibroker.com/devlog/





Your email settings: Individual Email|Traditional
Change settings via the Web (Yahoo! ID required)
Change settings via email: Switch delivery to Daily Digest | Switch to Fully Featured
Visit Your Group | Yahoo! Groups Terms of Use | Unsubscribe

__,_._,___