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

RE: [amibroker] javascript - exception



PureBytes Links

Trading Reference Links

Thanks much, appreciate the snippet of code.  In this case, the using the for loop seems to work pretty fast, though I understand using the array based approach would be faster.

 


From: amibroker@xxxxxxxxxxxxxxx [mailto:amibroker@xxxxxxxxxxxxxxx] On Behalf Of Steve Dugas
Sent: Monday, December 05, 2005 12:01 PM
To: amibroker@xxxxxxxxxxxxxxx
Subject: Re: [amibroker] _javascript_ - exception

 

Hi,

 

Not sure of all your details, but in general it is better to do all your work in native AFL if possible - it is much faster than embedding scripts in your code. It is also faster to avoid using loops if possible. This code should identify days that are the 5th consecutive up day:

 

N = 5;

UpDays = Close > ref( Close, -1);

ConsecUpdays = Sum( UpDays, N );

NConsecUpDays = ConsecUpDays == N;

 

Steve

----- Original Message -----

Sent: Monday, December 05, 2005 12:51 AM

Subject: RE: [amibroker] _javascript_ - exception

 

Basically, each time I encounter N consecutive up days, I want to perform some analysis to determine if a buy condition was met or not.  I think I understand what you have pointed out and it looks like I will have to iterate through all bars to accomplish what I want to do.

 

What I was hoping to do was do part in _javascript_ and part in AFL. For instance if N = 3, AFL would look like this I think:

            NPriceUpBars = C > Ref( C, -1 ) &&

Ref( C, -1 ) > Ref ( C, -2 ) &&

Ref (C, -2 ) > Ref( C, -3 ) ;

 

But what I wanted to do is perform the above “AND” (&&) operation in a loop so that all I would have to do is change my ‘N’ variable, and the code would work.

 

Have I explained what I am attempting to do?

 


From: amibroker@xxxxxxxxxxxxxxx [mailto:amibroker@xxxxxxxxxxxxxxx] On Behalf Of Dan Clark
Sent: Monday, December 05, 2005 12:18 AM
To: amibroker@xxxxxxxxxxxxxxx
Subject: RE: [amibroker] _javascript_ - exception

 

Hi.  “C” is an array of data.   PriceUp is a Boolean.    They are incompatible.

 

What are you trying to accomplish?  Where is this code being executed?   Why not use straight AFL?

 

Regards,

 

Dan.

 

 

 


From: amibroker@xxxxxxxxxxxxxxx [mailto:amibroker@xxxxxxxxxxxxxxx] On Behalf Of dimension@xxxxxxxxxxxxx
Sent: Sunday, December 04, 2005 9:00 PM
To: amibroker@xxxxxxxxxxxxxxx
Subject: [amibroker] _javascript_ - exception

 

Can anyone tell me why I am getting an error with the code below:

...

priceUp = True;

c1 = C;

for ( i = 1; i <= N; i++ )

{

       curBar = i * -1;

       priceUp = priceUp && c1 > Ref( C, curBar );

 

       if ( !priceUp ) break;

       ...

}

            …

 

I am getting an error on the line in red above.  The error is

Condition in IF, WHILE, FOR statements has to be Numeric or Boolean type.  You can not use array here, please use [] (array subscript operator) to access array elements”

 

(BTW< the Edit->Copy Error message function in Formula Editor is not working for me,  is this a bug?)

 

 




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 other support material please check also:
http://www.amibroker.com/support.html





YAHOO! GROUPS LINKS