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" <[EMAIL PROTECTED]> To: <amibroker@yahoogroups.com> 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@yahoogroups.com, "chorlton_c_hardy" <chorlton-c- > [EMAIL PROTECTED]> 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 > > > > >