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

[amibroker] Re: Looping - our previous discussion



PureBytes Links

Trading Reference Links

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
 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/amibroker/

<*> Your email settings:
    Individual Email | Traditional

<*> To change settings online go to:
    http://groups.yahoo.com/group/amibroker/join
    (Yahoo! ID required)

<*> To change settings via email:
    mailto:amibroker-digest@xxxxxxxxxxxxxxx 
    mailto:amibroker-fullfeatured@xxxxxxxxxxxxxxx

<*> To unsubscribe from this group, send an email to:
    amibroker-unsubscribe@xxxxxxxxxxxxxxx

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/