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

Re: [amibroker] script speed and backtest



PureBytes Links

Trading Reference Links

Dear Dan,

Well, it depends on a number of various factors.
When you use AFL formula without JScript/VBScript,
its speed can be comparable to compiled DLL code.

Because AFL works on the arrays, the operation
like 
graph0 = ( C - O ) / ( H - L );

(this is the formula for Balance of Market Power presented in S&C Sept. 2001)
execute in AFL at the speed matching compiled C++ code.

The things look different when you use JScript/VBScript
in your formula. Such code requires (in most cases)
iteration through the elements of several arrays.
Iteration in the JScript/VBScript is quite fast, but
all calculations in scripting engines are performed
using variant datatype, that makes them approx 2-3x slower
than using plain integers and floats in C++ and other
typed languages.
This all adds to the nature of scripting language that is
interpreted at run time - which means it must be
translated and then executed. The translation step
requires additional time compared to the native, compiled code.

As for the languages you mentioned - you will get definitely the
fastest code using regular DLL written in C/C++ (Delphi should work well
also) because DLL uses the same data types as AmiBroker internally,
so there is no need for data conversion.

ActiveX DLL that could be created in VB, Delphi (also in C++) will
be a little bit slower than DLL because of the need to convert AmiBroker arrays
to variant datatype.

All this also depends on how well you implement
the algorithm. You can write a very smart implementation
in JScript that can perform as well as (very) badly written C++ code.

To summarize:
in most cases compiled DLL should be 2x-10x faster than equivalent
VBScript/JScript code

Best regards,
Tomasz Janeczko
===============
AmiBroker - the comprehensive share manager.
http://www.amibroker.com


----- Original Message ----- 
From: "Dan Clark" <danclark@xxxx>
To: <amibroker@xxxxxxxxxxxxxxx>
Sent: Saturday, November 10, 2001 7:18 PM
Subject: RE: [amibroker] script speed and backtest


> Tomasz,
> 
> Question... When you say, "...10x faster than JScript.", does this mean
> that *any* compiled dll (C++, VB, Delphi..." would be faster than
> JScript (and by extension VBScript)? Or is your comment limited to C++?
> 
> Thanks and regards,
> 
> Dan.
> 
> -----Original Message-----
> From: Tomasz Janeczko [mailto:amibroker@x...] 
> Sent: Saturday, November 10, 2001 9:56 AM
> To: amibroker@xxxxxxxxxxxxxxx
> Subject: Re: [amibroker] script speed and backtest
> 
> Hi,
> 
> Yes, JScript and C++ are quite similar when you speak about syntax
> itself.
> And yes, properly written, compiled DLL would be min. 10x faster than
> JScript.
> 
> Best regards,
> Tomasz Janeczko
> ===============
> AmiBroker - the comprehensive share manager.
> http://www.amibroker.com
> 
> ----- Original Message ----- 
> From: "Stephane Carrasset" <nenapacwanfr@xxxx>
> To: <amibroker@xxxxxxxxxxxxxxx>
> Sent: Saturday, November 10, 2001 6:37 PM
> Subject: [amibroker] script speed and backtest
> 
> 
> > Tz,
> > 
> > I have tested today a combination of gann hilo with the
> > Nonlinear Ehlers Filters
> > something like this code below, but I have had 5 differents gann hilo 
> > ( 3 for the stock and 2 for a foreign() function).
> > the test was so slow!!
> > I am supposing that a plugin dll will be better and faster.
> > just tell me: I think javascript and c++ are a little similar.
> > 
> > stephane
> > 
> > 
> > pds=Optimize("pds",10,5,10,1);
> > mp = (High + Low)/2;
> > /* Distant Coefficient is calculated here using AFL scripting */ 
> > EnableScript("vbscript");
> > coef = mp;
> > <%
> > mp = AFL( "mp" )
> > coef = AFL( "coef" )
> > pds = AFL( "pds" )
> > For i = pds To UBound( mp )
> > coef( i ) = 0
> > For k = 1 To pds 
> > coef( i ) = coef( i ) + ( mp( i ) - mp( i - k ) )^2
> > Next
> > Next
> > AFL("coef") = coef
> > %>
> > Ehlers=Sum( coef * mp, pds )/Sum( coef, pds );
> > /*Gann HiLoShort*/
> > Ehs= Sum( coef * H, pds )/Sum( coef, pds );
> > Els= Sum( coef * L, pds )/Sum( coef, pds );
> > Hl=IIf(Close>Ref(Ehs,-1), 1,
> > IIf(Close<Ref(Els,-1), -1, 0));
> > Hv=ValueWhen(HL != 0,HL,1);
> > HiloSh=IIf(Hv==-1,ehs,els);
> > 
> > 
> > 
> > 
> > 
> > 
> > 
> > Your use of Yahoo! Groups is subject to
> http://docs.yahoo.com/info/terms/ 
> > 
> > 
> > 
> 
> 
> 
> 
> 
> Your use of Yahoo! Groups is subject to
> http://docs.yahoo.com/info/terms/ 
> 
> 
> 
> 
> 
> 
> Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/ 
> 
> 
>