Re: [amibroker] MetaStock's PREV

2009-06-16 Thread Mubashar virk
This is an excellent explanation and very example.
Thank you very much.

--
From: "Thomas Ludwig" 
Sent: Tuesday, June 16, 2009 7:00 PM
To: 
Subject: Re: [amibroker] MetaStock's PREV

> Hello,
>
> TJ once wrote:
>
> [quote]
> Hello,
>
> PREV in MS is needed because MS does NOT have looping.
>
> In AB, there are loop constructs so there is no need for PREV
> because loops give faster and more general way of solving coding problems.
>
> Since loops are more general they allow easy translation of every
> case where MS needs PREV.
>
> Statment like this:
> Z =(A*B)+(C*PREV);
>
> Using loop looks as follows:
>
> z = 0; // initialize
> for( i = 1; i < BarCount; i++ )
> {
>  prev = Z[ i - 1 ]; // PREV is previous value of Z.
>  Z[ i ] = A[ i ] * B[ i ] + C[ i ] * prev;
> }
>
> As you can see the statement is identical with the exception that
> AFL looping code uses [ ]  operator to access individual array elements.
>
> Good thing is that AFL looping code is BarCount-times faster than MS code.
> Since 5 years of EOD data is 1300 bars, AFL looping code is 1300 times 
> faster
> than MS in that case.
>
> It is also possible to use AMA/AMA2 instead of PREV:
>
> Z = AMA2( A, B, C );
>
> which is shorter but AMA is less general than looping code.
> [/quote]
>
> HTH
>
> Greetings,
>
> Thomas
>
>
> On 15.06.2009, 13:06:00 Mubashar virk wrote:
>> Hi all,
>>
>> Has any one worked out a universal AFL Function = the perversity in
>> MetaStock that is called  PREV.
>>
>> Thanks
>
>
> 
>
>  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
>
>
>




 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:
mailto:amibroker-dig...@yahoogroups.com 
mailto:amibroker-fullfeatu...@yahoogroups.com

<*> To unsubscribe from this group, send an email to:
amibroker-unsubscr...@yahoogroups.com

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



Re: [amibroker] MetaStock's PREV

2009-06-16 Thread Thomas Ludwig
Hello,

TJ once wrote:

[quote]
Hello,

PREV in MS is needed because MS does NOT have looping.

In AB, there are loop constructs so there is no need for PREV
because loops give faster and more general way of solving coding problems.

Since loops are more general they allow easy translation of every
case where MS needs PREV.

Statment like this:
Z =(A*B)+(C*PREV);

Using loop looks as follows:

z = 0; // initialize
for( i = 1; i < BarCount; i++ )
{
  prev = Z[ i - 1 ]; // PREV is previous value of Z.
  Z[ i ] = A[ i ] * B[ i ] + C[ i ] * prev;
}

As you can see the statement is identical with the exception that 
AFL looping code uses [ ]  operator to access individual array elements.

Good thing is that AFL looping code is BarCount-times faster than MS code.
Since 5 years of EOD data is 1300 bars, AFL looping code is 1300 times faster 
than MS in that case.

It is also possible to use AMA/AMA2 instead of PREV:

Z = AMA2( A, B, C );

which is shorter but AMA is less general than looping code.
[/quote]

HTH

Greetings,

Thomas


On 15.06.2009, 13:06:00 Mubashar virk wrote:
> Hi all,
>
> Has any one worked out a universal AFL Function = the perversity in
> MetaStock that is called  PREV.
>
> Thanks




 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:
mailto:amibroker-dig...@yahoogroups.com 
mailto:amibroker-fullfeatu...@yahoogroups.com

<*> To unsubscribe from this group, send an email to:
amibroker-unsubscr...@yahoogroups.com

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



Re: [amibroker] MetaStock's PREV

2009-06-15 Thread Mubashar virk
Thanks, TJ.
I will look into the archives.


From: Tomasz Janeczko 
Sent: Monday, June 15, 2009 3:43 PM
To: amibroker@yahoogroups.com 
Subject: Re: [amibroker] MetaStock's PREV






No, because it is sick idea implemented in MS because they don't have a normal 
loop construct in the language.
Metastock PREV essentially re-calculates entire array (number of bars)-times 
resulting (number of bars) performance degradation.
So if you have say 1 bars, the code runs 1 slower.

Everything that you do in MS using PREV should be coded using the loop in first 
place instead 
- and the resulting code will be 2 or 4 orders of magnitude faster.

Search the archive of the mailing list how to write loop equivalent.

Best regards,
Tomasz Janeczko
amibroker.com
  - Original Message - 
  From: Mubashar virk 
  To: amibroker@yahoogroups.com 
  Sent: Monday, June 15, 2009 1:06 PM
  Subject: [amibroker] MetaStock's PREV


  Hi all,

  Has any one worked out a universal AFL Function = the perversity in MetaStock 
that is called  PREV.

  Thanks



Re: [amibroker] MetaStock's PREV

2009-06-15 Thread Tomasz Janeczko
No, because it is sick idea implemented in MS because they don't have a normal 
loop construct in the language.
Metastock PREV essentially re-calculates entire array (number of bars)-times 
resulting (number of bars) performance degradation.
So if you have say 1 bars, the code runs 1 slower.

Everything that you do in MS using PREV should be coded using the loop in first 
place instead 
- and the resulting code will be 2 or 4 orders of magnitude faster.

Search the archive of the mailing list how to write loop equivalent.

Best regards,
Tomasz Janeczko
amibroker.com
  - Original Message - 
  From: Mubashar virk 
  To: amibroker@yahoogroups.com 
  Sent: Monday, June 15, 2009 1:06 PM
  Subject: [amibroker] MetaStock's PREV





  Hi all,

  Has any one worked out a universal AFL Function = the perversity in MetaStock 
that is called  PREV.

  Thanks