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

Re: [amibroker] Re: Translation into AFL



PureBytes Links

Trading Reference Links

Jayson,

I explained many times that PREV is ridiculous idea. Implementing PREV
would involve (and this is exactly what Metastock does), recalculating
array statement as many times as there are bars in currently selected symbols.

That makes PREV so slow. If you have Metastock you will see that single
PREV line may execute for several seconds.

The same statement in AFL using looping or AMA computes in 1/100 of the second
or less.

PREV is a killer for real-time operation. Try running Metastock RT with any PREV
formula and you will know what I mean.

Simply the idea behind PREV is sick and that's why I will not go into this direction.

Best regards,
Tomasz Janeczko
amibroker.com
----- Original Message ----- 
From: "Jayson" <jcasavant@xxxxxxxxxxx>
To: <amibroker@xxxxxxxxxxxxxxx>
Sent: Tuesday, July 29, 2003 4:49 PM
Subject: RE: [amibroker] Re: Translation into AFL


> Tomasz,
> We routinely see MS code using PREV on this forum. You have indeed shown
> many times that  AMA, or now, native loops, can be used to emulate MS PREV
> code. Since so many (including myself) still struggle with looping Would it
> make any sense for AB to simply offer PREV as a function?
> 
> Regards,
> Jayson
> 
> 
> -----Original Message-----
> From: Tomasz Janeczko [mailto:amibroker@xxxxxx]
> Sent: Tuesday, July 29, 2003 10:24 AM
> To: amibroker@xxxxxxxxxxxxxxx
> Subject: Re: [amibroker] Re: Translation into AFL
> 
> 
> Stephane,
> 
> This is not recursion but ITERATION.
> PREV in metastock is not the value of some funciton but
> just previous value of array (like in EMA formulation).
> 
> What is more: even if some algorithm is recursive it can be
> always rewriten to iterational form (there is a proof for this in computer
> science)
> 
> As for the question below, of course it can be written using loops
> (as any other algorithm).
> 
> BTW: Metastock people have very interesting habit of repeating
> code everywhere and not using variables at all (that's probably
> due to the 20 variable limit that metastock has)
> 
> We would need to 'unwind' this bad coding practice:
> 
> Original:
> If(LinearReg(C,13)>PREV,If(LinearReg(C,13)-(ATR(13)*2.5)>
> PREV,LinearReg(C,13)-(ATR(13)*2.5),PREV),LinearReg(C,13));
> 
> So, we have LinearReg(C,13) in this formula mentioned 4 times and
> ATR(13) mentioned 2 times.
> 
> So let us replace this with variables :
> 
> myLR = LinearReg( C, 13 );
> myATR = ATR( 13 );
> 
> result =
>    If(  myLR > PREV,
>         If( myLR - 2.5 * myATR > PREV,
>              myLR - 2.5 * myATR,
>              PREV ),
>       myLR );
> 
> Now let's rewrite to AFL native loops:
> 
> myLR = LinearReg( C, 13 );
> myATR = ATR( 13 );
> 
> result[ 0 ] = myLR[ 0 ];
> for( i = 1 ; i < BarCount; i++ )
> {
>    if( myLR[ i ] > result[ i - 1 ] )
>    {
>        temp = myLR[ i ] - 2.5 * myATR[ i ];
> 
>       if( temp > result[ i - 1 ] )    result[ i ] = temp;
>       else                                    result[ i ] = result[ i - 1 ];
>    }
>    else
>        result[ i ] = myLR[ i ];
> }
> 
> Graph0=result;
> 
> Graph1=Close;
> 
> This shows "DIRECT" rewriting of the formula. Resulting AFL code is 100+
> times faster than Metastock code.
> 
> 
> Best regards,
> Tomasz Janeczko
> amibroker.com
> ----- Original Message -----
> From: "Stephane Carrasset" <nenapacwanfr@xxxxxxxxx>
> To: <amibroker@xxxxxxxxxxxxxxx>
> Sent: Tuesday, July 29, 2003 3:16 PM
> Subject: [amibroker] Re: Translation into AFL
> 
> 
> > Hello,
> > I ask to me if recursion is not supported ( a function call itself
> > from within itself) is it possible to get this formula below ( with
> > PREV) in pure AFL with loops?
> >
> > stephane
> >
> > In amibroker@xxxxxxxxxxxxxxx, "Anthony Faragasso" <ajf1111@xxxx>
> > wrote:
> > > If(LinearReg(C,13)>PREV,If(LinearReg(C,13)-(ATR(13)*2.5)>
> > > PREV,LinearReg(C,13)-(ATR(13)*2.5),PREV),LinearReg(C,13));
> > >
> > >
> > > x=IIf(LinearReg(C,13) > Ref(LinearReg(C,13),-1),
> > > IIf(LinearReg(C,13)-(ATR(13)*2.5)>Ref(LinearReg(C,13)-(ATR(13)
> > *2.5),-1),Line
> > > arReg(C,13)-(ATR(13)*2.5),Ref(LinearReg(C,13)-(ATR(13)*2.5),-
> > 1)),LinearReg(C
> > > ,13));
> > >
> > >
> > > ---
> > > Outgoing mail is certified Virus Free.
> > > Checked by AVG anti-virus system (http://www.grisoft.com).
> > > Version: 6.0.504 / Virus Database: 302 - Release Date: 7/24/2003
> >
> >
> >
> > Send BUG REPORTS to bugs@xxxxxxxxxxxxx
> > Send SUGGESTIONS to suggest@xxxxxxxxxxxxx
> > -----------------------------------------
> > Post AmiQuote-related messages ONLY to: amiquote@xxxxxxxxxxxxxxx
> > (Web page: http://groups.yahoo.com/group/amiquote/messages/)
> > --------------------------------------------
> > Check group FAQ at:
> http://groups.yahoo.com/group/amibroker/files/groupfaq.html
> >
> > Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
> >
> >
> >
> 
> 
> 
> Send BUG REPORTS to bugs@xxxxxxxxxxxxx
> Send SUGGESTIONS to suggest@xxxxxxxxxxxxx
> -----------------------------------------
> Post AmiQuote-related messages ONLY to: amiquote@xxxxxxxxxxxxxxx
> (Web page: http://groups.yahoo.com/group/amiquote/messages/)
> --------------------------------------------
> Check group FAQ at:
> http://groups.yahoo.com/group/amibroker/files/groupfaq.html
> 
> Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
> 
> 
> 
> 
> 
> 
> Send BUG REPORTS to bugs@xxxxxxxxxxxxx
> Send SUGGESTIONS to suggest@xxxxxxxxxxxxx
> -----------------------------------------
> Post AmiQuote-related messages ONLY to: amiquote@xxxxxxxxxxxxxxx 
> (Web page: http://groups.yahoo.com/group/amiquote/messages/)
> --------------------------------------------
> Check group FAQ at: http://groups.yahoo.com/group/amibroker/files/groupfaq.html 
> 
> Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/ 
> 
> 
> 

------------------------ Yahoo! Groups Sponsor ---------------------~-->
Buy Toner for Your Printer or Fax at LaserTonerSuperstore.com-Save 55%!
We have your brand: HP, IBM, Canon, Xerox, Apple and many more for less!
http://www.LaserTonerSuperstore.com
http://us.click.yahoo.com/YmQqWC/qicGAA/ySSFAA/GHeqlB/TM
---------------------------------------------------------------------~->

Send BUG REPORTS to bugs@xxxxxxxxxxxxx
Send SUGGESTIONS to suggest@xxxxxxxxxxxxx
-----------------------------------------
Post AmiQuote-related messages ONLY to: amiquote@xxxxxxxxxxxxxxx 
(Web page: http://groups.yahoo.com/group/amiquote/messages/)
--------------------------------------------
Check group FAQ at: http://groups.yahoo.com/group/amibroker/files/groupfaq.html 

Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/