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

[amibroker] Dyanimic Position Size



PureBytes Links

Trading Reference Links





Terry --
Did you try it without using the [i] index?

If it still isn't working, try to divide an conquer, ie. find the
smallest code segment that still fails.

If that doesn't work, post the complete "smallest failing code"
along with any error messages you get.

BTW, AFL is almost identical to 'C'.  You may find it easier to always
use {} in if, if-else, while, do, etc. statements than just when
absolutely necessary.  ie. write:
<span
 >
<span
 >if (A5 == 1){
    A1= A2 = 0;
}
<span
 >
instead of:

if (A5 == 1) A1= A2 = 0;

Both are correct.  But using the first will adapt you to the language
structure more quickly. 

<span
 >if (A5 == 1) A1= A2 = 0;  A3=0;  // wouldn't
give you what you expected and would be difficult to trouble shoot.

-- Keith


Terry wrote:

  Re: [amibroker] How to get non array variables?
  Keith,
  
Thanks for pointing out my dumb error (vba habits die hard).
Unfortunately I still get the same error with that fix in.
  
Terry
  
PS to Bob: I will enlarge the text. It&#8217;s the transfer to my Mac that is
causing the size problem. I do virtually all email from my Mac to avoid
viruses.
--
  
  
  <span
 >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
        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) //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=IIf(A5=1,0,?);
 but a) I don&#8217;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.