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

Re: [amibroker] Re: Looping - our previous discussion



PureBytes Links

Trading Reference Links

GP,
 
I believe this is because you define i = j; outside of the j loop.  This is not what I do in my code.  i=j is defines within the brackets of the loop.
 
So if you adjust your code for that our results are the same, see below
 
rgds, Ed
 
 
waitPeriod = 5;
Setup2 =
ExRemSpan(1, waitPeriod-1
);

Setup =
1
;
for (i = 0; i < BarCount
- waitPeriod; i++) {

   
if
(Setup[ i ]) {

      
for (j = i + 1
; j < i + waitPeriod; j++) {

         Setup[ j ] =
0
;
         
         
if
(j == i + waitPeriod) {
         
            i = j;
         
         }

      }
      
      
//i = j;

   
   }

}



for (i = 0; i < BarCount
; i++)
_TRACE(StrFormat("%1.0f - %1.0f", Setup[i], Setup2[i]))
 
 
 
 
 
----- Original Message -----
From: gp_sydney
Sent: Friday, June 15, 2007 2:15 PM
Subject: [amibroker] Re: Looping - our previous discussion

Ed,

Thanks for the info about attachments. I've only just started using
this forum.

Without seeing where you've put the trace statements for i & j, it's a
bit hard to comment on your test.

However, if I run the following code, using a wait period of 5 to make
it shorter:

waitPeriod = 5;
Setup2 = ExRemSpan(1, waitPeriod-1);
Setup = 1;
for (i = 0; i < BarCount - waitPeriod; i++) {
if (Setup[ i ]) {
for (j = i + 1; j < i + waitPeriod; j++) {
Setup[ j ] = 0;
}
i = j;
}
}
for (i = 0; i < BarCount; i++)
_TRACE(StrFormat("%1.0f - %1.0f", Setup[i], Setup2[i]));

The loop code is the same as Bernard posted from your original
message, I've just added the ExRemSpan alternative as a comparison
then traced the output.

The results start off like this:

1 - 1
0 - 0
0 - 0
0 - 0
0 - 0
1 - 1
1 - 0
0 - 0
0 - 0
0 - 0
0 - 1
1 - 0
1 - 0
0 - 0
0 - 0
0 - 1
0 - 0
1 - 0
1 - 0
0 - 0

The ExRemSpan function correctly (by my interpretation of the
requirement) gives a one followed by four zeroes repeated throughout
the array. However, the loop code skips one bar, giving two ones at
the end of each block of four zeros, make the repeat length six rather
than five.

Also, the end of the array looks like this:

0 - 1
0 - 0
0 - 0
1 - 0
1 - 0
0 - 1
0 - 0
0 - 0
0 - 0
1 - 0
1 - 1
1 - 0
1 - 0
1 - 0

The loop code hasn't continued right to the end of the array. The
changes I suggested fix both issues, making the loop identical to the
ExRemSpan function.

The potential overflow of the j loop is only if the code is changed to
the correction I mentioned. It won't happen with the original code.

Regards,
GP

__._,_.___

Please note that this group is for discussion between users only.

To get support from AmiBroker please send an e-mail directly to
SUPPORT {at} amibroker.com

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

For other support material please check also:
http://www.amibroker.com/support.html





SPONSORED LINKS
Investment management software Investment property software Investment software
Investment tracking software Return on investment software

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

__,_._,___