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

Re: [amibroker] Re: Passing a variable into the Ref() function



PureBytes Links

Trading Reference Links

Ref accepts variable periods So all these workarounds are not required.

Ref( C, -x ) works perfectly fine.

Best regards,
Tomasz Janeczko
amibroker.com
----- Original Message ----- 
From: "dbwyatt_1999" <dbw451@xxxxxxxxxxxxx>
To: <amibroker@xxxxxxxxxxxxxxx>
Sent: Saturday, November 10, 2007 3:30 PM
Subject: [amibroker] Re: Passing a variable into the Ref() function


> Variables are arrays in AB, so Ref(Close,-x) probably would not 
> work.  If you have a predefined set of values for x, you could use 
> iif statements:
> 
> myValue = iif(x==5, Ref(C,-5), iif(x==10, Ref(C,-10), iif(x==15, Ref
> (C,-15),Null)));
> 
> However the best way to access variable array index offsets is to use 
> a loop:
> 
> i = 0;
> x = Param("x",10,1,100,1);
> for (i=x; i<BarCount; i++) {
>  myValue[i] = Close[i-x];
> }
> 
> Regards,
> 
> David
> 
> --- In amibroker@xxxxxxxxxxxxxxx, "chorlton_c_hardy" <chorlton-c-
> hardy@xxx> wrote:
>>
>> 
>> Hello All,
>> 
>> With regard to the Ref() function in AB, is there any way to pass a 
>> variable into it rather than using a specific value?
>> 
>> For example:
>> 
>> Rather than writing Ref(Close,-10), I want to write Ref(Close,-x) 
> where 
>> x has been defined earlier in my code.
>> 
>> 
>> Thanks in advance,
>> 
>> Chorlton
>>
> 
> 
> 
> 
> Please note that this group is for discussion between users only.
> 
> To get support from AmiBroker please send an e-mail directly to 
> SUPPORT {at} amibroker.com
> 
> For NEW RELEASE ANNOUNCEMENTS and other news always check DEVLOG:
> http://www.amibroker.com/devlog/
> 
> For other support material please check also:
> http://www.amibroker.com/support.html
> 
> Yahoo! Groups Links
> 
> 
> 
> 
>


Please note that this group is for discussion between users only.

To get support from AmiBroker please send an e-mail directly to 
SUPPORT {at} amibroker.com

For NEW RELEASE ANNOUNCEMENTS and other news always check DEVLOG:
http://www.amibroker.com/devlog/

For other support material please check also:
http://www.amibroker.com/support.html
 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/amibroker/

<*> Your email settings:
    Individual Email | Traditional

<*> To change settings online go to:
    http://groups.yahoo.com/group/amibroker/join
    (Yahoo! ID required)

<*> To change settings via email:
    mailto:amibroker-digest@xxxxxxxxxxxxxxx 
    mailto:amibroker-fullfeatured@xxxxxxxxxxxxxxx

<*> To unsubscribe from this group, send an email to:
    amibroker-unsubscribe@xxxxxxxxxxxxxxx

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/