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

[amibroker] Re: Having a nasty time figuring this APL out.



PureBytes Links

Trading Reference Links

Possible ? ... Sure ...

Assuming that i and j are variables then

i = 42;
j = 39;
if (Volume[i] == Volume[j])
{
    X = 1;
else
    X = 0;
}

However ... If you are going to want to do this sort of thing at 
multiple points along the array and given AFL's imbedded capability 
to perform instructions across entire arrays in a single instruction 
WITHOUT having to write your own loops then ...

X = iif(Volume == Ref(Volume, -3), 1, 0);

Will value X at EACH POINT along the array ... 

--- In amibroker@xxxxxxxxxxxxxxx, "Homar Simpson" <x77777x@xxx> wrote:
>
>    At this point I have a question. If I want to do a simple boolean
> test , assigning the result to a simple var, of two members of the
> 'volume' array , is that possible, or am I forced to be concerned 
with
> the details of arrays.
> 
>  And I do want to exit the loop at any failure, since 1 failure is
> enough to disqualify the symbol.
> 
> 
> 
> --- In amibroker@xxxxxxxxxxxxxxx, "Paul Ho" <paultsho@> wrote:
> >
> >  
> > Iif operates on both arrays and straight variables, but "if" only
> operates
> > on variables or individual elements
> > 
> > PassTest = IIf(testvolume == False,False,PassTest ); is 
equivalent to
> > 
> > For(i=0; i< barcount; i++)
> > {
> > 	if(testvolume[i] == 0)PassTest[i] = false;
> > 	else PassTest[i] = PassTest[i]; // this is a straight 
translation
> > but is redundant really
> > }
> > Now if you use if(PassTest == false) then it will generate an 
error
> as it
> > expects an element of the array and not the array itself. That
> statement is
> > actually ambiguous, if one element is false, you don't really want
> to stop
> > processing the loop, because other elements in this array might 
well be
> > true.
> > 
> > 
> > 
> > 
> > ________________________________
> > 
> > From: amibroker@xxxxxxxxxxxxxxx [mailto:amibroker@xxxxxxxxxxxxxxx]
> On Behalf
> > Of Homar Simpson
> > Sent: Tuesday, 5 December 2006 5:11 PM
> > To: amibroker@xxxxxxxxxxxxxxx
> > Subject: [amibroker] Re: Having a nasty time figuring this APL 
out.
> > 
> > 
> > 
> > As I mentioned I've been programming for 30 years.
> > 
> > What I'm doing here is assigning a SINGLE boolean variable based 
on
> > the comparison of array contents. If I did this in VB or VBA , 
there
> > would be no issue. Are you saying the boolean takes on the
> > characteristic of the tested array? I think Tradestation does
> > something like that.
> > 
> > If thats the case , how would you 
> > 
> > If I say Var1=x(5)-y(2), then Var1 is not an array. 
> > 
> > Explain how:
> > if (PassTest==False) i=0;
> > generates an array error??
> > 
> > Please explain the actual reason, I've read the docs and there's
> > nothing there to make this clear.
> > 
> > ================================================================
> > Days=Param("Days To Test",3,1,15,1);
> > 
> > PassTest=True;
> > 
> > for(i=Days; i>0 ; i--) 
> > 
> > {
> > TestVolume = IIf((Ref(Volume ,-i+1)> Ref(Volume ,-
i)),True,False); 
> > 
> > PassTest = IIf(testvolume == False,False,PassTest );
> > 
> > if (PassTest==False) i=0;
> > 
> > }
> > 
> > _TRACE("--------------------------------- ");
> > 
> > FL1=PassTest;
> > FL2=Close >Param("ClosingPrice",5,0,999999,1); 
> > 
> > Filter = FL1 AND FL2;
> > 
> > AddColumn(Close,"Close",1.4);
> > AddColumn(Volume,"Volume",1.0);
> > AddTextColumn( FullName(), "Full name", 77);
> > 
> > AddColumn(Ref(Volume,-1),"Volume -1",1.0);
> > AddColumn(Ref(Volume,-2),"Volume -2",1.0);
> > AddColumn(Ref(Volume,-3),"Volume -3",1.0);
> > 
> > 
> > 
> >  
> > 
> > Send instant messages to your online friends
> http://au.messenger.yahoo.com
> >
>



Content-Description: "AVG certification"
No virus found in this incoming message.
Checked by AVG Free Edition.
Version: 7.5.432 / Virus Database: 268.15.9/573 - Release Date: 12/5/2006 4:07 PM