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

Re: [amibroker] AFL comments



PureBytes Links

Trading Reference Links


Hi Dima and all,
 
<BLOCKQUOTE 
>
<DIV 
>From: 
Dima 
Rasnitsyn 
To: <A title=amibroker@xxxxxxxxx 
href="">amibroker@xxxxxxxxxxx 
Sent: Sunday, January 21, 2001 7:49 
PM
Subject: RE: [amibroker] AFL 
comments


<SPAN 
><FONT 
face=Verdana>Hello Tomasz,
<SPAN 
><FONT 
face=Verdana> 
<SPAN 
><FONT 
face=Verdana>I was really amazed by AFL speed. Now I understand the reason &#8211; 
thank you.
<SPAN 
><FONT 
face=Verdana> 
<SPAN 
><FONT 
face=Verdana>As for my suggestion #1, just in case I was not clear enough, I 
mean the CONST argument can be NUMBER (not a VECTOR). Probably the better 
example would be
<SPAN 
><FONT 
face=Verdana>N = -1;
<SPAN 
><FONT 
face=Verdana>prevClose = ref (close, 
N);
<FONT face=Verdana 
color=#993366><SPAN 
>Anyway, 
this limitation can be workaround (at least in my case), so I do not thing it 
is worth any significant effort&#8230;
<SPAN 
><FONT 
face=Verdana color=#000000>Well, in fact you CAN use numbers right now.The only 
thing to take care are implict type 
conversions
<FONT face=Verdana 
color=#000000><SPAN 
>performed 
by AFL engine. For example if you write<SPAN 
class=EmailStyle20><SPAN 
>
number = min(5, 2 
);buy= ref( cross( macd(), 0 ), number );
sell = 0;
 
You will get "Bad args" error 
because number is an array (vector) as a result of implict type conversion made 
by AmiBroker
during execution of min function. 
 
To switch back from array to a 
number you have to use lastvalue() or ValueWhen() functions as shown 
below:
<FONT face=Verdana 
size=2>number = lastvalue( min( 5, 2 ) );buy= ref( cross( macd(),0 ), 
number );
sell = 0;
 
Hope it helps.
<FONT face=Verdana 
size=2> 
<SPAN 
><FONT 
face=Verdana color=#000000>Best regards,Tomasz 
Janeczko===============AmiBroker - the comprehensive share 
manager.<FONT 
face=Verdana>http://www.amibroker.com
<FONT face=Arial color=#993366 
size=2><SPAN 
> 
<BLOCKQUOTE 
>
<FONT face=Tahoma color=black 
size=2><SPAN 
>-----Original 
Message-----From: Tomasz 
Janeczko [mailto:tj@xxxx]<SPAN 
>Sent: Sunday, January 21, 2001 5:23 
AMTo: 
amibroker@xxxxxxxxxxx<SPAN 
>Subject: Re: [amibroker] AFL 
comments
<FONT face="Times NewRoman" 
size=3><SPAN 
> 
<FONT face=Tahoma color=black 
size=2>Hello 
Dima,<SPAN 
>
<FONT face="Times NewRoman" 
color=black size=3><SPAN 
> <FONT 
color=black><SPAN 
>
<FONT face=Tahoma color=black 
size=2>Thank 
you for your e-mail. I think that the best news for you is that soon 
AmiBroker will support charting/analysis plug-ins (in the form of 
DLLs)<SPAN 
>
<FONT face=Tahoma color=black 
size=2>that 
will enable writing systems/indicators in any 
programming language. <SPAN 
>
<FONT face="Times NewRoman" 
color=black size=3><SPAN 
> <FONT 
color=black><SPAN 
>
<FONT face=Tahoma color=black 
size=2>As for 
suggestions #1 and #2 - implementing such things is not so easy in AFL because 
AFL is vector-based language. This means<SPAN 
>
<FONT face=Tahoma color=black 
size=2>that 
when you write " something = close * volume" the engine performs vector 
multiplication at once (this is the reason why<FONT 
color=black><SPAN 
>
<FONT face=Tahoma color=black 
size=2>AFL is 
10 or more times faster than other formula languages found in other stock 
analysis software).... BUT I will think about it :-)<FONT 
color=black><SPAN 
>
<FONT face="Times NewRoman" 
color=black size=3><SPAN 
> <FONT 
color=black><SPAN 
>
<FONT face=Tahoma color=black 
size=2>Point 
#3 - yes, external functions would be nice :-) <FONT 
color=black><SPAN 
>
<FONT face="Times NewRoman" 
color=black size=3><SPAN 
> <FONT 
color=black><SPAN 
>
<FONT face="Times NewRoman" 
color=black size=2>Best 
regards,Tomasz Janeczko===============AmiBroker - the 
comprehensive share manager.<SPAN 
><SPAN 
>http://www.amibroker.com<FONT 
color=black><SPAN 
>
<DIV class=Section1 
>
<P class=MsoNormal 
><FONT 
face="arial ce" color=black size=2><SPAN 
>----- Original 
Message ----- <SPAN 
>
<P class=MsoNormal 
><FONT 
face="arial ce" color=black size=2><SPAN 
>
From:<FONT face="arial ce" 
color=black size=2><SPAN 
> <A 
title=rasnitsyn@xxxx href="">Dima Rasnitsyn 
<SPAN 
>

<P class=MsoNormal 
><FONT 
face="arial ce" color=black size=2><SPAN 
>To:<FONT 
face="arial ce" color=black size=2><SPAN 
> <A 
title=amibroker@xxxxxxxxxxx 
href="">amibroker@xxxxxxxxxxx 
<SPAN 
>
<P class=MsoNormal 
><FONT 
face="arial ce" color=black size=2><SPAN 
>Sent:<FONT 
face="arial ce" color=black size=2><SPAN 
> Sunday, 
January 21, 2001 4:56 AM<FONT face="arial ce" color=black 
size=2><SPAN 
>
<P class=MsoNormal 
><FONT 
face="arial ce" color=black size=2><SPAN 
>Subject:<FONT 
face="arial ce" color=black size=2><SPAN 
> RE: 
[amibroker] AFL comments<FONT face="arial ce" color=black 
size=2><SPAN 
>
<P class=MsoNormal 
><FONT 
face="Times New Roman" color=black size=3><SPAN 
> <FONT 
color=black><SPAN 
>
<P class=MsoNormal 
><SPAN 
class=EmailStyle19><SPAN 
>Hello 
Tomasz!
<P class=MsoNormal 
><SPAN 
class=EmailStyle19><SPAN 
> 
<P class=MsoNormal 
><SPAN 
class=EmailStyle19><SPAN 
>Thank 
you very much for your response.
<P class=MsoNormal 
><SPAN 
class=EmailStyle19><SPAN 
> 
<P class=MsoNormal 
><SPAN 
class=EmailStyle19><SPAN 
>As a 
software engineer (yes, you are right), I would like to ask for three more 
enhancements. I&#8217;m not sure whether they are valuable for the majority of 
AmiBroker customers &#8211; long-term stock investors, but they would be definitely 
beneficial for short-term and commodity traders, especially for those using 
complicated custom indicators and/or trading 
systems.
<P class=MsoNormal 
><SPAN 
class=EmailStyle19><SPAN 
> 
<DIV class=Section1 
>
<P class=MsoNormal 
><SPAN 
class=EmailStyle19><SPAN 
>1)<FONT 
face="Times New Roman" size=1><SPAN 
>    
<FONT 
face=Arial color=navy size=2><SPAN 
>It 
would be nice if the functions like ref(), valuewhen(), etc. with an argument 
of type CONST will accept a NUMBER, so it will be possible to 
do:
<DIV class=Section1 
>
<P class=MsoNormal 
><SPAN 
class=EmailStyle19><SPAN 
>N = 
MIN (a, b);
<P class=MsoNormal 
><SPAN 
class=EmailStyle19><SPAN 
>prevOpen 
= ref (open, N);
<P class=MsoNormal 
><SPAN 
class=EmailStyle19><SPAN 
> 
<DIV class=Section1 
>
<P class=MsoNormal 
><SPAN 
class=EmailStyle19><SPAN 
>2)<FONT 
face="Times New Roman" size=1><SPAN 
>    
<FONT 
face=Arial color=navy size=2><SPAN 
><SPAN 
> For/while loops and IF-THEN-ELSE 
constructs would be useful as well. The last would save complicated 
multi-level IIF constructs.
<DIV class=Section1 
>
<P class=MsoNormal 
><SPAN 
class=EmailStyle19><SPAN 
> 
<DIV class=Section1 
>
<P class=MsoNormal 
><SPAN 
class=EmailStyle19><SPAN 
>3)<FONT 
face="Times New Roman" size=1><SPAN 
>    
<FONT 
face=Arial color=navy size=2><SPAN 
>Functions 
(AFL file name where the function is defined), or simple &#8216;include&#8217; 
construction can help to reduce code size and complexity for sophisticated 
custom indicators and/or trading 
systems.
<DIV class=Section1 
>
<P class=MsoNormal 
><SPAN 
class=EmailStyle19><SPAN 
> 
<P class=MsoNormal 
><SPAN 
class=EmailStyle19><SPAN 
> 
<P class=MsoNormal 
><SPAN 
class=EmailStyle19><SPAN 
>As for 
my 47Kb formula, I think about 80% of this code is targeted to workaroundthe 
current limitations of AFL listed in the message #859 (<A 
href="">http://www.egroups.com/message/amibroker/859). 
It&#8217;s my system for trading NYBOT Sugar (I&#8217;ve not tested it onother 
commodities yet), and the indicators showing graphically the account balance 
and results of each trade. BTW, it would be very useful if the automatic 
analysis tool will graph the account value and trade results. 

<P class=MsoNormal 
><SPAN 
class=EmailStyle19><SPAN 
>I can 
send this code directly to you if you are curious to see how a mad software 
engineer can write 47K code in 4-th generation scripting language to implement 
a trading system based on 2 simple price formations <SPAN 
class=EmailStyle19><SPAN 
><SPAN 
>J<SPAN 
class=EmailStyle19><SPAN 
>
<P class=MsoNormal 
><SPAN 
class=EmailStyle19><SPAN 
> 
<P class=MsoNormal 
><SPAN 
class=EmailStyle19><SPAN 
>Thank 
you,
<P class=MsoNormal 
><SPAN 
class=EmailStyle19><SPAN 
>Dima
<P class=MsoNormal 
><SPAN 
class=EmailStyle19><SPAN 
> 
<DIV class=Section1 
>
<P class=MsoNormal 
><FONT 
face=Tahoma color=black size=2><SPAN 
>-----Original 
Message-----From: AmiBroker 
Support [mailto:support@xxxx]<SPAN 
>Sent: Saturday, January 20, 2001 6:05 
AMTo: 
amibroker@xxxxxxxxxxx<SPAN 
>Subject: Re: [amibroker] AFL 
comments<SPAN 
>
<P class=MsoNormal 
><FONT 
face="Times New Roman" color=black size=3><SPAN 
> <FONT 
color=black><SPAN 
>
<P class=MsoNormal 
><FONT 
face="Courier New" color=black size=2><SPAN 
>Hello 
Dima,<SPAN 
>You 
must be a software developer, Dima! Your requests are so 
detailed!I am glad and thankful that you point out all these 
things.> I'd like to request a few minor enhancements 
to AFL interpreter.>> 1) The AFL buffers (in 
Guru Comments, indicator builder, etc.) are> limited to about 
32Kb [AFL code for my trading system is currently 47K].> Once 
AFL code is larger, it becomes impossible to edit it in the window 
(but> still possible to load file). It'd be great if you can 
make this buffer> *unlimited*Wow! 47K formula 
- that sounds truly interesting. Maybe you will uncover some 
secretsabout this one?As for the limit I can 
enlarge it easily to 64K but then limitation of Windows 
95/98comes up:"Windows 95 implements some window 
management features in 16 bits. The use of 16 bits imposes some restrictions 
on parameters infunctions and messages and places limits on 
internal storage. In some cases, Windows 95 provides features that can beused 
to avoidthese restrictions and limitations. For example, the 
standard edit control is limited to somewhat less than 64 kilobytes (K) 
oftext" - taken from Microsoft Developer 
NetworkThere are of course no such limitations on Windows 
NT/2000 so this is not an issue for these platforms.Or... I 
can switch to so-called "Rich-edit" controls that do not have such limitation 
(but are slower...)>> 2) Subsequent 
comments are not recognized, i.e. if I have> /*   
comment one */> /* comment two */> 
or> a = b; // comment one> /* comment two 
*/> I get an error message pointing to the leading slash of 
the> second commentThis one should be fixed 
long time ago :-(> 3) result of Boolean (or any other) 
operation including an array which> value is {EMPTY} for 
particular date is {EMPTY}.  I think {EMPTY} should be> 
considered as 0. Example:> sell = exitLongPosition OR 
enterShortPosition;> If my first trade for the time period is 
Long, sell will have> {EMPTY} value until my first short 
trade. 1 in exitLongPosition will be> ignored because of 
{EMPTY} value of enterShortPosition.I guess you are right 
(but for boolean operations only). Why not for all 
operations?Simply because {EMPTY} is used to mark that thereare 
no valid datafor given bar. For example moving average valueis 
NOT available for the first<range> number of bars. So if 
you base your other calculations on the resultsof MA you should 
not include these invalid data. AFL engine detects {EMPTY}values 
and skips them so nested functions/operators work only on valid 
data.Best regards,Tomasz 
Janeczko===============AmiBroker - the comprehensive 
share manager.<A 
href="">http://www.amibroker.com<FONT 
color=black><SPAN 
>
<FONT face="Times NewRoman" 
color=black size=3><BR 
><BR 
><FONT 
color=black><SPAN 
>