PureBytes Links
Trading Reference Links
|
Hi,
for performance reasons only loops and huge AFL script costructs (usually include files) are good candidate for converting them to compiled code. As long as you use built-in AB functions like (MA, EMA, etc, or use its array operators) it is quite fast.
Loops and accessing array elements (indexing) are slow (compared to complied code). Depending on the "content" of the loop a decent compiled code runs 5-100 times faster. (Think of it. AB knows only float, string an array types. An AFL loop counter is a float... Indexing and pointer arithmetrics need interger types...)
However, when you write C code, you have to take care of AFL Null values, and pointer arithmetrics and write a lot of glue code. This is quite error prone.
I have written a lot of C plug-in code. It just took to much time. So I created a .Net SDK. With this you can still focus on the trading logic while coding. Array operators are coded in x86 so they are as fast as in AB. They take care of Nulls as well. Calling a built-in function is much simpler:
// plotting fast average close price with alternating color
AFGraph.Plot(myFastEma, "Ema5",
AFTools.Iif(mySlowMa < myFastEma, Color.DarkGreen, Color.Brown),
Style.Line);
If you write C or .Net complied code you may face one issue. You have to build your plug-in agains an AB version and you may face incompatibility issues if you run your plug-in under a different AB version. This never occures in AFL.
Regards,
Y
--- In amibroker@xxxxxxxxxxxxxxx, "jooleanlogic" <jooleanl@xxx> wrote:
>
> For loops and array access, yes there is a significant speed difference in C.
>
> Just think of it this way Sid,
> your afl loop in a dll will take about as long as any other inbuilt afl function does.
> If an MA call on your machine takes a few milliseconds, then that's roughly as long as your afl loop in a dll will take, depending of course on what you're doing in that loop.
>
> To give you an idea, on my computer, the following simple afl code takes about 200ms on half a million bars. The equivalent Cum(1) call takes about 5ms.
>
> mycum = 0;
> for (bar=1; bar<BarCount; bar++){
> mycum[bar] = mycum[bar-1] + 1;
> }
>
> Going by the Amibroker profiler, it's roughly 100ms for the loop itself and 40-50ms for each array access. In C, the loop itself is virtually a non event of a few milliseconds, freeing up a couple of hundred ms for your actual code inside the loop.
> This is why you should always try and use the built in functions and array arithmetic operators where possible.
>
> Jules.
>
>
> --- In amibroker@xxxxxxxxxxxxxxx, "Rob" <sidhartha70@> wrote:
> >
> > Hi,
> >
> > Sorry if this is a silly question... but having come a long way with AFL and feeling like I can do pretty much everything I need to within AFL, I am now wondering about the use of JScipt/VBScript and DLL's...
> >
> > In what circumstances would one use JScipt/VBScript or write a custom DLL...? What are the advantages to their use...?
> >
> > If someone would be kind enough to just give me a brief outline I'd appreciate it...
> >
> > TIA
> >
>
------------------------------------
**** IMPORTANT PLEASE READ ****
This group is for the discussion between users only.
This is *NOT* technical support channel.
TO GET TECHNICAL SUPPORT send an e-mail directly to
SUPPORT {at} amibroker.com
TO SUBMIT SUGGESTIONS please use FEEDBACK CENTER at
http://www.amibroker.com/feedback/
(submissions sent via other channels won't be considered)
For NEW RELEASE ANNOUNCEMENTS and other news always check DEVLOG:
http://www.amibroker.com/devlog/
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:
amibroker-digest@xxxxxxxxxxxxxxx
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/
|