PureBytes Links
Trading Reference Links
|
All,
I'm counting the number of 1's and 0's from arrays which are the results
of our well-known set of indicators. The 1's and 0's actually represent
peaks and valleys and I'd like an indication of how many of them there
are within a specific period starting from the current bar and going back
myPeriod bars. I've noticed something strange though.
If I try to count in this manner....
for ( i = 0; i < myPeriod; i++ ) {
if ( myarray[i] == 1 )
total1 = total1 + 1;
else
total2 = total2 + 1;
}
I stumble across a runtime error that admonishes me for having a subscript
that is not between 0 ... (BarCount-1). However the following snippet of
code avoids the runtime error...
for ( i = 0; i < BarCount && i < myPeriod; i++ ) {
if ( myarray[i] == 1 )
total1 = total1 + 1;
else
total2 = total2 + 1;
}
Now this is really strange since I know "myPeriod" is far less than the
BarCount. Could it be that AFL operations aren't striclty linear in that
the results of my array operations preceeding the for loop are not yet
complete? Could it be that I don't understand how array subscripts work?
So what is the proper way to count the number of 1's and 0's in an array
starting from the most recent bar and working back?
-- John
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 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/
<*> 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/
|