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

Re: [amibroker] Re: Repetitive Statements with FOR (?)



PureBytes Links

Trading Reference Links

Dimitris,

Problem is that I don't know what exactly Ken was after.
I provided some explanation based on wild guesses.
Let us wait for Ken to get back to us, describing the high-level goal
so we can help him better.

Best regards,
Tomasz Janeczko
amibroker.com
----- Original Message ----- 
From: "DIMITRIS TSOKAKIS" <TSOKAKIS@xxxxxxxxx>
To: <amibroker@xxxxxxxxxxxxxxx>
Sent: Tuesday, November 11, 2003 10:48 AM
Subject: [amibroker] Re: Repetitive Statements with FOR (?)


> Tomasz,
> As I see
> A1=Ref(A0,-1);
> A2=Ref(A0,-2);
> etc
> which, in last analysis, is array A0 and nothing more.
> Dimitris Tsokakis
> --- In amibroker@xxxxxxxxxxxxxxx, "Tomasz Janeczko" <amibroker@xxxx> 
> wrote:
> > Repetitive Statements with FOR (?)Ken,
> > 
> > In your example: A0 is an ARRAY variable, A1 is another 
> (independent) ARRAY variable and so
> > on. So you have N array variables with different names.
> > 
> > A[i] is not the same as Ai.
> > A[i] is i-th element of A array variable.
> > Ai is the (array) variable that has the name of Ai
> > 
> > On the other hand you can no create variable names dynamically like 
> A+i = ..something
> > 
> > You could simplify the code by declaring a function:
> > 
> > function mycolor( array, shift )
> > {
> >  array = Ref( array, shift );
> >  color = IIf( array<3,colorRed,array > 3 AND array 
> <5,colorYellow,colorGreen);
> > 
> >   return color;
> > }
> > 
> > and then just write:
> > A1 = mycolor( Tot, -1 );
> > A2 = mycolor( Tot, -2 );
> > A3 = mycolor( Tot, -3 );
> > A4 = mycolor( Tot, -4 );
> > A5 = mycolor( Tot, -5 );
> > 
> > You would be able to wrap it up in a loop if you could declare 
> multi-dimensional arrays but you can't do this right now
> > (unless you use JScript or VBScript)
> > 
> > Please describe your high-level goal.
> > 
> > Quote from "how to ask questions the smart way":
> > 
> > "If you are trying to find out how to do something,begin by 
> describing the goal. Only then describe the particular step towards 
> it that you are blocked on.
> > Often, people who need technical help have a high-level goal in 
> mind and get stuck on what they think is one particular path towards 
> the goal. They come for help with the step, but don't realize that 
> the path is wrong. It can take a lot of effort to get past this."
> > 
> > 
> > Best regards,
> > Tomasz Janeczko
> > amibroker.com
> >   ----- Original Message ----- 
> >   From: Ken Close 
> >   To: AmiBroker List 
> >   Sent: Tuesday, November 11, 2003 4:33 AM
> >   Subject: [amibroker] Repetitive Statements with FOR (?)
> > 
> > 
> >   As I venture into the land of more "pure" programming constructs, 
> I stumble.  Any help?
> > 
> >   I have a complex series of variables calculating values for 
> today, yesterday, up to Ref(xx,-20)
> > 
> >   Instead of
> > 
> >   A0 = IIf(Tot<3,colorRed,IIf(Tot>3 AND 
> Tot<5,colorYellow,colorGreen);
> > 
> >   A1 = IIf(Ref(Tot,-1)<3,colorRed,IIf(Ref(Tot,-1)>3 AND Ref(Tot,-1)
> <5,colorYellow,colorGreen);
> > 
> >   A2 = IIf(Ref(Tot,-2)<3,colorRed,IIf(Ref(Tot,-2)>3 AND Ref(Tot,-2)
> <5,colorYellow,colorGreen);
> > 
> >   And repeat this 19 times, back 19 days; 
> > 
> >   I wanted to try and use a For loop, and tried the following.  But 
> I get all sorts of error messages, the most frequent of which 
> is "Type Mismatch, number expected but array found."
> > 
> > 
> > 
> >   for(i=0; i>19; i++)
> > 
> >   {
> > 
> >   A[i]=IIf(Ref(Tot,-i)<3,colorRed,IIf(Ref(Tot,-i)>3 AND Ref(Tot,-i)
> <5,colorYellow,colorGreen);
> > 
> >   }
> > 
> >   I tried A+I and that did not work either 
> > 
> >   "Error 3.
> > 
> >   Condition in IF, WHILE, FOR statements
> > 
> >   has to be Numeric or Boolean type.
> > 
> >   You can not use array here,
> > 
> >   please use [] (array subscript operator)
> > 
> >   to access array elements"
> > 
> >   The "A"s are arrays, so the A[i] seemed like the right way to go, 
> but then the Type Mismatch.
> > 
> >   I know the answer is probably simple, but I can not see it.
> > 
> >   Help?
> > 
> >   Ken
> > 
> > 
> >         Yahoo! Groups Sponsor 
> >               ADVERTISEMENT
> >              
> >        
> >        
> > 
> >   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 the Yahoo! Terms of 
> Service.
> 
> 
> 
> 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/ 
> 
> 
> 

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