PureBytes Links
Trading Reference Links
|
It works. But apparenty one of AND condition parts are not met.
Always use the exploration to find out why your code does not work.
Display every column as exploration
BTW: lots of redundancy in your code. IIF not needed. Multiplicaiton not needed.
The code below will allow you to find the answers yourself. Run as exploration and see
x = H == HHV(H, 30);
y = - BarsSince(x);
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 );
Filter = 1;
AD = AccDist();
AddColumn( x, "x" );
AddColumn( Ref( AD, y ), "Ref(AD,y)" );
AddColumn( AD, "AccDist" );
Best regards,
Tomasz Janeczko
amibroker.com
----- Original Message -----
From: "chorlton_c_hardy" <chorlton-c-hardy@xxxxxxxxxxxxx>
To: <amibroker@xxxxxxxxxxxxxxx>
Sent: Saturday, November 10, 2007 11:31 PM
Subject: [amibroker] Re: Passing a variable into the Ref() function
>
> 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@xxxxxxxxxxxxxxx, "Tomasz Janeczko" <groups@xxx>
> 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" <dbw451@xxx>
>> 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@> 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
>
>
>
>
>
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/
|