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

Re: [amibroker] general question on loops and arrays.



PureBytes Links

Trading Reference Links



Maybe this little example will help:

Assume we want an array B equal to an array A shifted to the right one bar:
   B =
Ref(A, -1);
AB calculates the result by doing something like:
  
for(i=1; i<BarCount; i++) B[i]= A[i-1];
or:
  
for(i=BarCount-1; i>0; i--) B[i]= A[i-1];

However, if we try to shift an array A right by one bar using:
   A = Ref(A, -1);
and AB calculates the result by doing something like:
   for(i=1; i<BarCount; i++) A[i]= A[i-1];
the result is that all a[i] are set equal to a[0], not what we wanted.

AB could have calculated our desired result with something like:
   for(i=BarCount-1; i>0; i--) A[i]= A[i-1];
But AB is just a computer program.  It can't know our desires, unless we tell it, in its own language.

-- Keith


Noah Bender wrote:
Here is a general question for someone like me who has had amibroker for a few months.
 
I am trying to really get to the bottom of difference between array proccessing and loop processing. I see my code incorporates both of them and I think there may be some problems because I am not entirely sure of the difference between them. So hopefully one of the gurus will be kind enough to really list the differences. i found the userguide to only give a cursory explanation.
 
thanks in advance
noah
 


__._,_.___


**** 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

__,_._,___