logo
Welcome Guest! To enable all features please Login or Register.

Notification

Icon
Error

Options
Go to last post Go to first unread
dct73  
#1 Posted : Wednesday, July 29, 2009 3:24:29 PM(UTC)
dct73

Rank: Newbie

Groups: Registered, Registered Users, Subscribers
Joined: 7/26/2009(UTC)
Posts: 7

I've been looking at the following code and it brought up this question: Is Stop1 presumed to be zero right off the bat, or do I have to call out Stop1:=0?

Stop1:=If( PREV < L,
{then} If(( H - 3*ATR(10) ) >= PREV,
{then} ( H - 3*ATR(10) ),
{else} PREV),
{else (L <= PREV)}
( H - 3*ATR(10) ));

Thanks
mstt  
#2 Posted : Monday, August 3, 2009 3:34:27 PM(UTC)
mstt

Rank: Advanced Member

Groups: Registered, Registered Users, Subscribers
Joined: 7/25/2005(UTC)
Posts: 1,042

Was thanked: 57 time(s) in 54 post(s)

Yes, an initial PREV value of zero is assumed. You can’t predefine a variable with PREV in it but what works in some situations is that the variable can be “seeded” on the first bar from within – see the following exponential moving average formula as an example of this.

{Exponential Moving Average}

Pds:=Input("Periods",1,1000,10);

Rate:=2/(Min(Cum(1),Pds)+1);

If(Cum(1)=0,C,PREV*(1-Rate)+C*Rate);

Your formula can be reduced to just two PREVs as follows.

X:=H-3*ATR(10);

If(PREV<L,Max(X,PREV),X);

In some cases a PREV-based variable can be rewritten to remove PREV altogether, although I don’t think it’s possible with your example.

Roy

Users browsing this topic
Guest (Hidden)
Similar Topics
Elimination of Prev Function (Basic Coding Techniques)
by rockerzeus 10/6/2015 6:18:39 PM(UTC)
Need help with PREV function on Highlight (Formula Assistance)
by Leverage 11/4/2013 6:17:00 PM(UTC)
Avoid PREV function (Formula Assistance)
by MetaReader 7/16/2013 8:18:13 AM(UTC)
PREV function (Formula Assistance)
by klim 2/12/2013 2:03:47 AM(UTC)
PREV Function (MetaStock)
by v.trader 11/22/2009 2:10:08 PM(UTC)
Help for the Code With Non Prev Function (Formula Assistance)
by uasish 10/27/2006 10:19:32 AM(UTC)
Trying to Remove the PREV Function [RESOLVED] (Formula Assistance)
by lcl 1/22/2006 4:06:11 PM(UTC)
Removal of the PREV function [RESOLVED] (Formula Assistance)
by RUAGOODP 7/21/2005 5:00:31 PM(UTC)
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.