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

RE: [amibroker] Re: Question on User Defined Arrays (Static)



PureBytes Links

Trading Reference Links




<FONT face=Arial color=#0000ff 
size=2>Hello Sam,
<FONT face=Arial color=#0000ff 
size=2> 
<FONT face=Arial color=#0000ff 
size=2>For temprorary storage you can simply use A[0] to A[BarCount-1] , if you 
need a lot of storage you should set current a stock with lots of data as 
BarCount changes for each stock you make current.
<FONT face=Arial color=#0000ff 
size=2> 
<FONT face=Arial color=#0000ff 
size=2>In some cases I have used the array backwards, i.e starting with 
[BarCount-1] and counting down, this always puts your data at the latest date 
and makes it easy to display for debugging. An added advantage in doing it this 
way is that you can use standard afl functions on your data. For example if you 
have twenty numbers stored at the end of the array you can find the Moving 
Average simply with LastValue(MA(YourArray,20)).
<FONT face=Arial color=#0000ff 
size=2> 
<FONT face=Arial color=#0000ff 
size=2>I don'tthink that the cell [0] and up are also dates or bar-indices 
doesn't really effect their usage.
<FONT face=Arial color=#0000ff 
size=2> 
<FONT face=Arial color=#0000ff 
size=2>best regards,
<FONT face=Arial color=#0000ff 
size=2>herman
<FONT face=Arial color=#0000ff 
size=2> 
<FONT face=Arial color=#0000ff 
size=2> 

  <FONT face=Tahoma 
  size=2>-----Original Message-----From: samgrayy 
  [mailto:samgrayy@xxxxxxxx]Sent: December 4, 2003 1:21 
  PMTo: amibroker@xxxxxxxxxxxxxxxSubject: [amibroker] Re: 
  Question on User Defined Arrays (Static)Thank you 
  William , What is missing here is how do I declare the array A[5]. 
  Arrays in Amibroker are temporal .. (i.e. there is an entry pertrading 
  day). In this case we have an Array that does not depend on aparticular 
  day, It is just to create less error prone and more 
  elegantsoftware.I hope this explains it.Thanks 
  again,Sam--- In amibroker@xxxxxxxxxxxxxxx, "William 
  Peters"<williampeters@xxxx> wrote:> Sam,> > 
  It's still a little unclear because some of the code you wrote isreally 
  not doing too much (those IIF functions) but take a look atthis, you 
  should be able to work it from here.> When you have questions like this 
  its often a better approach togive a high level description of the 
  problem, like 'I'm trying tocreate a performance indicator that oscillates 
  around the zero line'etc and that way you might get a response with a 
  vastly differentapproach.> > ZM = 0;> 
  i=0;>  do>  { >   ZM = ZM + IIf 
  (ComputeValue( A[i] ) > 0 , A[i], ZM); >   i++; 
  >  } > while( i < 5 ); > > > 
  Regards,> William Peters> www.amitools.com> > 
  > > -----Original Message-----> From: samgrayy 
  [mailto:samgrayy@xxxx]> Sent: Wednesday December 3, 2003 8:54 
  PM> To: amibroker@xxxxxxxxxxxxxxx> Subject: [amibroker] Re: 
  Question on User Defined Arrays (Static)> > > Thank you 
  William , > > What I need to do is to iterate through values, 
  right now what I am> doing is something like: > > ZM = 0 
  ; > ZM = IIf (ComputeValue( A5M ) > 0   , A5M, ZM); 
  > ZM = IIf (ComputeValue( A4M ) > 0   , A4M, ZM); > 
  ZM = IIf (ComputeValue( A3M ) > 0   , A3M, ZM); > ZM = IIf 
  (ComputeValue( A2M ) > 0   , A2M, ZM); > ZM = IIf 
  (ComputeValue( A1M ) > 0   , A1M, ZM); > > What I 
  would like to do instead is to say: > A[1] = A1M; A[2]=A2M ; A[3] = 
  A3M; A[4] = A4M; A[5] = A5M; > >  i=1;>  
  do>  { >   ZM = IIf (ComputeValue( A[i] ) > 
  0   , A[i], ZM); >   i++; >  } 
  >  while( i < 6 ); >   > > This 
  way I can make the code more readable and I can change the Array> only 
  without the rest of the program. > > In vbscript there is the 
  'for each' functionality which would be close.> > Thanks 
  again,> I really appreciate all the comments.> > 
  Sam> > > --- In amibroker@xxxxxxxxxxxxxxx, "William 
  Peters"> <williampeters@xxxx> wrote:> > Hi,> 
  > > > I'm finding it a little difficult to work out exactly what 
  your> trying to do so if you could post the  whole script it would 
  be good.> > > > A few things..> > > > 
  1) You don't use the Dim statement in AFL, just initialise the> 
  variables directly.> > > > 2) Here is the structure of the 
  Do While Loop:> > > > i=0;> > do> > { 
  > >    i++; > > } > > while( i 
  < 100 ); > > WriteVal( i ); > > > > > 
  > 3) You have left off one parenthesis from your function 
  "(A[i],M[i]]"> > I think it should be "(A[i],M[i])"> > 
  > > > > Regards,> > William Peters> > 
  www.amitools.com> > > > > > > > 
  -----Original Message-----> > From: samgrayy 
  [mailto:samgrayy@xxxx]> > Sent: Wednesday December 3, 2003 8:08 
  PM> > To: amibroker@xxxxxxxxxxxxxxx> > Subject: 
  [amibroker] Re: Question on User Defined Arrays (Static)> > > 
  > > > I guess there is no response. I hope somebody takes a look 
  at this.> > Thanks in advance, > > SG> > 
  > > --- In amibroker@xxxxxxxxxxxxxxx, "samgrayy" 
  <samgrayy@xxxx> wrote:> > > Hi All, > > > 
  > > > With the intro of the new looping constucts in AFL,  
  the scripting> > hosts are not as useful as they were. > > 
  > I am struggling a bit with the programming of a loop as follows: > 
  > > > > > Dim Zones(3), Multipliers(3)> > > 
  A[0]= SomeValue; > > > A[1]= AnotherValue; > > > 
  A[2]= ..; > > > M[0]= ..; > > > M[1]= ..; > 
  > > M[2]= ..; > > > > > > Result=0 ; > 
  > > i = 2;> > > while( i >= 0 ){  > > 
  > Result= Result+ Function (A[i],M[i]] ; > > > }> > 
  > > > > Notice here that the arrays do not change with time 
  (such as the> > price array for example).> > > > 
  > > > > > Thanks in advance for any hint,> > > 
  Sam> > > > > > > > Send BUG REPORTS to 
  bugs@xxxx> > Send SUGGESTIONS to suggest@xxxx> > 
  -----------------------------------------> > Post AmiQuote-related 
  messages ONLY to: amiquote@xxxxxxxxxxxxxxx > > (Web page: <A 
  href="">http://groups.yahoo.com/group/amiquote/messages/)> 
  > --------------------------------------------> > Check group FAQ 
  at:> <A 
  href="">http://groups.yahoo.com/group/amibroker/files/groupfaq.html 
  > > > > Your use of Yahoo! Groups is subject to> <A 
  href="">http://docs.yahoo.com/info/terms/> 
  > > > Send BUG REPORTS to bugs@xxxx> Send 
  SUGGESTIONS to suggest@xxxx> 
  -----------------------------------------> Post AmiQuote-related 
  messages ONLY to: amiquote@xxxxxxxxxxxxxxx > (Web page: <A 
  href="">http://groups.yahoo.com/group/amiquote/messages/)> 
  --------------------------------------------> Check group FAQ at:<A 
  href="">http://groups.yahoo.com/group/amibroker/files/groupfaq.html 
  > > Your use of Yahoo! Groups is subject to<A 
  href="">http://docs.yahoo.com/info/terms/Send 
  BUG REPORTS to bugs@xxxxxxxxxxxxxSend SUGGESTIONS to 
  suggest@xxxxxxxxxxxxx-----------------------------------------Post 
  AmiQuote-related messages ONLY to: amiquote@xxxxxxxxxxxxxxx (Web page: <A 
  href="">http://groups.yahoo.com/group/amiquote/messages/)--------------------------------------------Check 
  group FAQ at: <A 
  href="">http://groups.yahoo.com/group/amibroker/files/groupfaq.html 
  Your use of Yahoo! Groups is subject to the <A 
  href="">Yahoo! Terms of Service. 







Yahoo! Groups Sponsor












Send BUG REPORTS to bugs@xxxxxxxxxxxxx
Send SUGGESTIONS to suggest@xxxxxxxxxxxxx
-----------------------------------------
Post AmiQuote-related messages ONLY to: amiquote@xxxxxxxxxxxxxxx 
(Web page: http://groups.yahoo.com/group/amiquote/messages/)
--------------------------------------------
Check group FAQ at: http://groups.yahoo.com/group/amibroker/files/groupfaq.html



Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.