PureBytes Links
Trading Reference Links
|
more sharpened, a PREVIOUS send excellent PREV explanation
by Gary Randell and dito excellent Equis Support's reply to it.
Note Equis' sentence:
PREV represents the value for the previous time period ONLY FOR THE
STATEMENT IN WHICH IT EXISTS.
more sharper sharpened, further down below find Ken Andersen's
valid substitutes for PREV
Regards,
Ton Maas
ms-irb@xxxxxxxxxxxxxxxx
Dismiss the ".nospam" bit (including the dot) when replying.
Homepage http://home.planet.nl/~anthmaas
================================================
I think you are not quite correct in your definition of PREV and how it
works.
This is how it works.
PREV represents the value for the previous time period ONLY FOR THE
STATEMENT IN WHICH IT EXISTS.
V1 := Mov(c,30,s) + PREV;
if( V1 > 30, PREV, 10);
In the first line, PREV represents the value for this line in the
formula only. It has no reference to any data manipulated by the if()
function in the second line. The reference to PREV in the second line
DOES NOT REPRESENT THE PREVIOUS PERIOD'S VALUE FOR THE FIRST LINE. It
represents the PREVIOUS value only for the if() function itself.
PREV does not reference the previous period's value for an entire
multi-statement formula. As stated, it only represents the previous
value for the statement in which it exists.
I hope this helps.
Equis Support
http://www.equis.com/
http://www.equis.com/customer/support/
Please include previous email answers and questions in your response.
Equis and MetaStock and MetaStock Professional are registered trademarks
of Equis International. Achelis Binary Wave, The DownLoader, Expert
Advisor, OptionScope, Quotecenter, and Smart Charts are trademarks of
Equis International.
------------------------------------------------------------------------------
-----Original Message-----
From: Randall_Gary
Sent: Monday, November 09, 1998 11:03 AM
To: MetaStock Group
Subject: MetaStock PREV constant bugs
While trying to develop a simple trading system in MetaStock I ran into
a stone wall trying to use the PREV constant. I've reduced my findings
about the PREV constant to the following simple indicators to demonstrate the
problems.
If you will copy the following code into a new indicator and run it against any set
of data with more than 40 bars you will see the results. Remove the braces {}
around the code you want to test, and isolate code with braces you don't want to test.
If anyone can see where I've gone wrong or suggest workarounds for these
problems I'd really appreciate it.
I suspect that MetaStock is referencing a pointer instead of a value, but
the results don't seem consistent.
Gary Randall -- Brunswick, Maine
{ Demonstration of PREV bugs }
{----------------------------------------------}
{
This works.
Conclusion: Can use PREV in direct assignment.
Note that first result doesn't plot even
though it must be assigned correctly.
}
{If(Cum(1) = 10, 1, PREV + 1);}
{----------------------------------------------}
{
This works.
Conclusion: Can use PREV in direct assignment
even if it was set from a variable.
Note that first result plots correctly.
}
{
Series := If(Cum(1) = 10, 1, PREV + 1);
Series;
}
{----------------------------------------------}
{
This works.
Conclusion: Can test PREV directly.
}
{If(PREV = 10, 1, PREV + 1);}
{----------------------------------------------}
{
This works.
Conclusion: Can test PREV directly even if it
was set from a variable.
}
{
Series := If(PREV = 10, 1, PREV + 1);
Series;
}
{----------------------------------------------}
{
This doesn't work. Result is always one,
therefore, Series variable is always zero.
Conclusion: Can't assign PREV to variable.
}
{
Series := PREV;
If(Cum(1) = 10, 1, Series + 1);
}
{----------------------------------------------}
{
This doesn't work. Result never resets to
one, therefore, Series is never 10.
Conclusion: Can't assign PREV to variable.
}
{
Series := PREV;
If(Series = 10, 1, PREV + 1);
}
{----------------------------------------------}
{
This really gets interesting.
Trade entry test works OK by setting day 10
value to 1. Trade exit test works OK by
setting day 34 to zero. It should then assign
zero for the rest of the chart. However, it
starts incrementing from 25 instead.
Conclusion: PREV is not being reset to zero on
exit test, even though the indicator plots a
zero.
}
{ Imagine this is trade entry test to enter }
{ trade on day 10 }
Series :=
If(Cum(1) = 10, 1, If(PREV > 0, PREV + 1, 0));
{ Imagine this is trade exit test to exit }
{ trade on 25th day in trade (day 34) }
Series := If(Series = 25, 0, Series);
Series;
{----------------------------------------------}
================================================
Chuck,
There's a way to create suitable substitutions for the PREV function in some instances.
The examples that Equis gives in the on-line Help can be substituted like this:
-PREV- -Substitute-
1) ((H+L+C)/3) + PREV is the same as: Cum(((H+L+C)/3))
---------------------------------------------------------------------------------------------------
2) (If(C>Ref(C,-1),1,-1)*VOLUME)+PREV Cum((If(C>Ref(C,-1),1,-1)*VOLUME))
----------------------------------------------------------------------------------------------------
3) (CLOSE*0.18)+(PREV*0.82) (Mov(C,10,E)*0.18) + (Mov(C,10,E) * 0.82)
-----------------------------------------------------------------------------------------------------
The substitutes for examples 1 and 2 return identical values as there PREV counterparts.
The #3 substitute is almost identicle, usually less than 1/100ths off.
Ken Andersen
================================================
Taken from the on-line help:
The PREV constant allows you to create self-referencing formulas.
A self referencing formula is one that is able to reference the "previous"
period's value of itself. For example, the following is an example of a self
referencing formula:
((H+L+C)/3) + PREV
This simple formula divides the high, low, and closing prices by 3 and then
adds this value to yesterday's value of the ((H+L+C)/3).
================================================
----- Original Message -----
From: David Bozkurtian <dbozkurtian@xxxxxxxxxxx>
To: <metastock@xxxxxxxxxxxxx>
Sent: woensdag 2 februari 2000 19:32
Subject: Re: Formula Question - Chandelier Exit
> Thanks,
>
> It's a pleasure to be part of this group. You folks are sharp and willing to
> help.
>
> David
>
>
> From: "j seed" <jseed_10@xxxxxxxxxxx>
> Reply-To: metastock@xxxxxxxxxxxxx
> To: metastock@xxxxxxxxxxxxx
> Subject: Re: Formula Question - Chandelier Exit
> Date: Wed, 02 Feb 2000 16:08:03 GMT
>
> David,
>
> In answer to your question about something quicker than PREV; Ref((),-1)
> works for me!
>
> J.
>
>
>
> >
> >Here's a side question. In VB and VBA, there are some functions in the
> >language which should be avoided because they are too slow. There are
> >workarounds to them. The PREV function in MS System Tester seems to be one
> >of them. Does anyone know of a quicker (possibly long hand) workaround
> >which
> >will speed things up?
> >
> >Thanks in advance
> >
> >David
> >
>
> ______________________________________________________
> Get Your Private, Free Email at http://www.hotmail.com
>
>
> ______________________________________________________
> Get Your Private, Free Email at http://www.hotmail.com
>
>
|