Hello Tomasz, If Ref() accepts variable periods, can you clarify why the code below doesn't work?
x = IIf(H == HHV(H, 30), 1, 0); y = BarsSince(x); y = y*-1; Buy1 = x AND AccDist() > Ref(AccDist(),y); Buy2 = x AND AccDist() > Ref(AccDist(),-5); PlotShapes( shapeUpArrow*Buy1, colorGreen, 0, L, -10 ); PlotShapes( shapeUpArrow*Buy2, colorBlue, 0, H, -10 ); The Buy2 signal will plot with no problems but the Buy1 signal won't. I assumed this was because of the variable y in the Ref() function. However, if Ref() can accept variables then can you explain what I'm doing wrong? Any help much appreciated, Chorlton --- In amibroker@yahoogroups.com, "Tomasz Janeczko" <[EMAIL PROTECTED]> wrote: > > 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- > > hardy@> 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 > > > > > > > > > > >