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

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



PureBytes Links

Trading Reference Links

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 per
trading day). In this case we have an Array that does not depend on a
particular day, It is just to create less error prone and more elegant
software.

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 is
really not doing too much (those IIF functions) but take a look at
this, you should be able to work it from here.
> When you have questions like this its often a better approach to
give a high level description of the problem, like 'I'm trying to
create a performance indicator that oscillates around the zero line'
etc and that way you might get a response with a vastly different
approach.
> 
> 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@x...]
> 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@x...]
> > 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: 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
> 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: 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
http://docs.yahoo.com/info/terms/


------------------------ Yahoo! Groups Sponsor ---------------------~-->
Buy Ink Cartridges or Refill Kits for your HP, Epson, Canon or Lexmark
Printer at MyInks.com. Free s/h on orders $50 or more to the US & Canada.
http://www.c1tracking.com/l.asp?cid=5511
http://us.click.yahoo.com/mOAaAA/3exGAA/qnsNAA/GHeqlB/TM
---------------------------------------------------------------------~->

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 http://docs.yahoo.com/info/terms/