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

Notification

Icon
Error

Options
Go to last post Go to first unread
gojuice  
#1 Posted : Friday, February 8, 2008 3:23:51 PM(UTC)
gojuice

Rank: Newbie

Groups: Registered, Registered Users
Joined: 2/8/2008(UTC)
Posts: 3

Hi all,

Is there a way to enter a variable into the 'nth' parameter of the ValueWhen function?

The Forum.dll doesn't contain that function. I've also tried the +Prev-Prev trick but nothing plots in the indicator window.

For example I've typed in ValueWhen(LastValue(data array+Prev-Prev),x,counter).

That's the correct format, right?

Any suggestions?

Thanks

mstt  
#2 Posted : Thursday, February 14, 2008 9:24:31 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)

Hi GJ

As yet there is no publicly-available variable ValueWhen() function for MetaStock. This might change when/if Wabbit updates the Forum DLL, but that's not a foregone conclusion at this point.

The +PREV-PREV option does work, at least in some situations. The following formula is just one example. From memory, with this formula at least, I think the PREV variable has to be an unnamed output variable. In other words you can't name the PREV variable and then use its name as an output or to feed other code lines. If you attempt to use the name of the PREV variable as an output you'll probably discover that it does plot, but only on the last bar. All other bars are N/A. At least that's what happens with the formula below. It's a PREV variable characteristic that I haven't figured out how to get around yet.

Try changing the last line if this formula by giving it a name and then outputting that name and you'll see what I mean. Keep your EOD chart to less than 1000 bars or you'll be waiting a while for it to plot.

If you're wondering what this formula does, The "I" variable is a descending counter that points back the appropriate number of weekly CLOSEs so that a weekly plot of CLOSE can be recreated (and right adjusted) on successive EOD bars.

Regards

Roy

MetaStock Tips & Tools

{Weekly Close Compression}

{2004 Roy Larsen, rlarsen@man.quik.co.nz}

{use on daily charts with Jose Silva's

"Calendar Week counter"}

F:=Input("End of Week, 5=Friday 6=Saturday 7=Sunday",5,7,5);

Q:=Input("Display Mode, 0=Static 1=Dynamic 2=Test",0,2,1);

{0=Display, update on Friday when possible}

{1=Display, update on each new bar}

{2=Backtest, update on first bar of new week}

G:=LastValue(Highest(Sum(DayOfWeek()=F,5))=5);

I:=Fml("Calendar Week counter");

I:=Abs(I-ValueWhen(2-G,1,I)); M:=G OR I>0;

F:=G OR (DayOfWeek()=F AND I=0);

A:=LastValue(Cum(1)-1)=Cum(1);

B:=ValueWhen(2,1,A);

J:=If(F,1,If(Alert(F,2)=0 AND M,2,0));

J:=If(A+LastValue(J)>2 OR B+(Q=1)=2,1,J);

J:=If(G,1,If(Q=2 OR Cum(J)<=1,M*2,J));

K:=ValueWhen(1,J,If(J=1,C,ValueWhen(2-G,1,C)));

K:=ValueWhen(1,K>0,K);

F:=LastValue(Cum(1))-Cum(1);

G:=LastValue(Cum(J>0))-Cum(J>0);

I:=1+F-G;

M:=LastValue(Cum(J>0));

I:=ValueWhen(1,F<=M,I);

ValueWhen(LastValue(I+PREV-PREV),J,K);

uasish  
#3 Posted : Wednesday, February 20, 2008 2:24:13 PM(UTC)
uasish

Rank: Advanced Member

Groups: Registered, Registered Users
Joined: 8/13/2005(UTC)
Posts: 170

Thanks: 7 times
Ahh ! now i got the answer of the puzzle,once again thanks Roy.
Users browsing this topic
Guest (Hidden)
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.