PureBytes Links
Trading Reference Links
|
Terry --
You must use == instead of = for the conditional test in the 'if'
statement. For example:
if (A5 == 1) A1= A2 = 0;
-- Keith
Terry wrote:
How to get non array variables?
Problem: I need a
variable as a number and not as an array to use in a subscript (see
code below). Is there a way to declare variables as array or numeric? I
found the global vs. local, but not array vs. numeric.
Description: I have several conditions calculated that result in arrays
A1...A9. The values of these arrays are either 1, 0 or -1. When A5 = 1,
I want to zero out all other arrays for that bar. I keep getting this
error:
Error <font
color="#ff00ff">6.
Array subscript has to be a number
The Code:
//Compute values of A1-A9 first.
i=BarCount; //I put
this in to try and force a non-array variable. It doesn't work with or
without this line.
i=BarIndex();
if (A5[i]=1) <font
color="#008000">//A5 trumps all other A rules so make all others = 0
A1[i]=A2[i]=A3[i]=A4[i]=A6[i]=A7[i]=A8[i]=A9[i]=<font
color="#ff00ff">0;
I suppose there is an array solution that could look something like
this:
A1=A2=A3=A4=A6=A7=A8=A9=<font
color="#0000ff">IIf(A5=1,0,?);
but a) I don’t know what to put in the not
true part that will leave all the values unchanged and, b) I would like
to know how to obtain a number variable.
I could also do this 8 times (once for each array), but it seems so
un-elegant:
A1=IIf(A5=1,0,A1);
A2=IIf(A5=1,0,A2);
...
Thanks in advance for any solutions.
--
Terry
Check AmiBroker web page at:
http://www.amibroker.com/
Check group FAQ at: <a
href="">http://groups.yahoo.com/group/amibroker/files/groupfaq.html
Check AmiBroker web page at:
http://www.amibroker.com/
Check group FAQ at: http://groups.yahoo.com/group/amibroker/files/groupfaq.html
Yahoo! Groups Sponsor
ADVERTISEMENT
Yahoo! Groups Links
To visit your group on the web, go to:http://groups.yahoo.com/group/amibroker/
To unsubscribe from this group, send an email to:amibroker-unsubscribe@xxxxxxxxxxxxxxx
Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.
|