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

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



PureBytes Links

Trading Reference Links

Ken,
before the last 19 days, what is your preference for the color of A ?
If, for example, it is black, then what you ask is a single line
A=iif(cum(1)<Lastvalue(cum(1))-19,colorblack,IIf(Tot<3,colorRed,IIf
(Tot>3 AND Tot<5,colorYellow,colorGreen)));
Note also that colorYellow is nothing but 42.
Dimitris Tsokakis
--- In amibroker@xxxxxxxxxxxxxxx, "Ken Close" <closeks@xxxx> wrote:
> 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 ---------------------~-->
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/