Hi - REF operates on the entire array like most other AB functions. It 
shifts the array by the number of bars you specify. You can plot a couple of 
different REF's to see it in action.  When you need to use IF with an array, 
use IIF instead -

MARY = IIF( Ref( Lowest_ROC_NUM, 0 ) == 9, 10, 0 );

Also, saying
Ref( Lowest_ROC_NUM, 0 )
shifts the array by zero bars, so it is the same as just using the original 
array...
Lowest_ROC_NUM



----- Original Message ----- 
From: "trfy1120" <trfy1...@yahoo.com>
To: <amibroker@yahoogroups.com>
Sent: Thursday, August 26, 2010 3:58 PM
Subject: [amibroker] Misunderstanding of Arrays


>I have an array called lowest_roc_num.
>
> If I use the test:
>
>     JOHN = Ref(Lowest_ROC_NUM,0)==9;
>
> JOHN gets the value of zero or 1 appropriately.
>
> If I use the syntax:
>
>    if (Ref(Lowest_ROC_NUM,0) == 9)
> MARY=10;
>
> I get an error message saying that the condition in an IF, WHILE or FOR 
> statement must be numeric or boolean, you cannot use an array here.  It 
> then says to use [] to refer to an element of the array.
>
> I have two problems.  First, I thought REF was referring to an element of 
> the array rather than the whole array and, second, I don't know how to 
> refer to the current bar using [].
>
> Thanks for any help.
>
> TRFY
>
>
>
> ------------------------------------
>
> **** IMPORTANT PLEASE READ ****
> This group is for the discussion between users only.
> This is *NOT* technical support channel.
>
> TO GET TECHNICAL SUPPORT send an e-mail directly to
> SUPPORT {at} amibroker.com
>
> TO SUBMIT SUGGESTIONS please use FEEDBACK CENTER at
> http://www.amibroker.com/feedback/
> (submissions sent via other channels won't be considered)
>
> For NEW RELEASE ANNOUNCEMENTS and other news always check DEVLOG:
> http://www.amibroker.com/devlog/
>
> Yahoo! Groups Links
>
>
>
> 


Reply via email to