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

Re: [Metastockusers] WEEKLY INDICATOR



PureBytes Links

Trading Reference Links

Hi Norman
 
 
"E" is a reserved letter (like C, H, L, O, V, W etc) and can't be used as a variable name. Pick another name.
 
 
Kind regards
 
Roy
----- Original Message -----
From: ruagoodp
Sent: Tuesday, May 31, 2005 9:22 PM
Subject: [Metastockusers] WEEKLY INDICATOR

Hi Roy,

I have finished setting up this daily indicator

x1:=If(Ref(H,-2),< ,Ref(C,-7),
If(Ref(H,-2),<,Ref(C,-8),
If(H,<,Ref(L,-5),
If(H,<,Ref(L,- 6),0,1),1),1),1);
x2:=If(Ref(L,-2),> ,Ref(C,-7),
If(Ref(L,-2),>,Ref(C,-8),
If(L,>,Ref(H,-5),
If(L,>,Ref(H,- 6),0,1),1),1),1);
SubValues:=(x1) * (x2) * (H-Ref(H,-2) ) +((x1) * (x2) * (L-Ref(L,-2)) );
AbsDailyVal:=(Abs(H-Ref(H,-2)) + Abs(L-Ref(L,-2)));
Sum((SubValues),8) / Sum((AbsDailyVal),8)



into a weekly indicator:


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:=LastValue(Cum(1))=Cum(1);
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));
Hw:=HighestSince(1,M,H);
Hw:=ValueWhen(1,J,If(J=1,Hw,ValueWhen(2-G,1,Hw)));
Lw:=LowestSince(1,M,L);
Lw:=ValueWhen(1,J,If(J=1,Lw,ValueWhen(2-G,1,Lw)));
Cw:=ValueWhen(1,J,If(J=1,C,ValueWhen(2-G,1,C)));
Hw:=ValueWhen(1,Hw>0,Hw);
Lw:=ValueWhen(1,Lw>0,Lw);
Cw:=ValueWhen(1,Cw>0,Cw);

A:=If(ValueWhen(3,J,Hw),< ,ValueWhen(8,Cw>0,Cw),
If(ValueWhen(3,J,Hw),<,ValueWhen(9,Cw>0,Cw),
If(Hw,<,ValueWhen(6,J,Lw),
If(Hw,<,ValueWhen(7,J,Lw),0,1),1),1),1);
B:=If(ValueWhen(3,J,Lw),> ,ValueWhen(8,Cw>0,Cw),
If(ValueWhen(3,J,Lw),>,ValueWhen(9,Cw>0,Cw),
If(Lw,>,ValueWhen(6,J,Hw),
If(Lw,>,ValueWhen(7,J,Hw),0,1),1),1),1);
X:=Cum((J>0)*A);
Y:=Cum((J>0)*B);
D:=(X) * (Y) * (Hw-ValueWhen(3,J,Hw) ) +((X) * (Y) *
(Lw-ValueWhen(3,J,Lw)));
E:=(Abs(Hw-ValueWhen(3,J,Hw) + Abs(Lw-ValueWhen(3,J,Lw)));
Sum((D),8) / Sum((E),8)


As far as I can see I have done everything correctly however
metatstock rejects my 2nd last line

E:=(Abs(Hw-ValueWhen(3,J,Hw) + Abs(Lw-ValueWhen(3,J,Lw)));
Sum((D),8) / Sum((E),8)

What have I done wrong?

Cheers

Norman








Yahoo! Groups Links