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

Notification

Icon
Error

3 Pages<123
Options
Go to last post Go to first unread
arnevanveen  
#41 Posted : Saturday, March 25, 2006 12:59:36 PM(UTC)
arnevanveen

Rank: Advanced Member

Groups: Registered, Registered Users
Joined: 10/15/2005(UTC)
Posts: 31
Location: The Netherlands

I tried to adjust the Bearish divergence indicator to a positive reversal indicator (based on RSI). While the Divergence is about high's, the Reversal is about lows. I think it is just a start, because of my limited knowledge of the MS-language. The signals are not always valid. I'm curious for opinions about it , so don't hesitate with commentary :D . Arne TrPer:=Input("Through %",0,100,15); pds1:=Input("RSI periods",1,21,14); x:=RSI(pds1); Tr1:=Trough(1,x,TrPer); Tr2:=Trough(2,x,TrPer); Tr3:=Trough(3,x,TrPer); Tr4:=Trough(4,x,TrPer); TrHi:=ValueWhen(1,tr1<>Ref(tr1,-1),L); {Enter Long condition} Entrytrig:= x<Mov(x,9,E) AND x<60 AND (tr1<tr2 AND tr2<>Ref(tr2,-1) AND trHi>ValueWhen(2,tr2<>Ref(tr2,-1),L) OR tr1<tr3 AND tr3<>Ref(tr3,-1) AND trHi>ValueWhen(3,tr3<>Ref(tr3,-1),H) OR tr1<tr4 AND tr4<>Ref(tr4,-1) AND trHi>ValueWhen(4,tr4<>Ref(tr4,-1),H)); Entrytrig;
Jose  
#42 Posted : Saturday, March 25, 2006 2:17:29 PM(UTC)
Jose

Rank: Advanced Member

Groups: Registered, Registered Users
Joined: 1/19/2005(UTC)
Posts: 1,065
Location: Koh Pha-Ngan, Earth

Was thanked: 2 time(s) in 2 post(s)
Don't forget that the last leg of Trough(1,x,... is dynamic. i.e., today's signal may not appear on the chart until a few days later. jose '-)
arnevanveen  
#43 Posted : Saturday, March 25, 2006 3:01:16 PM(UTC)
arnevanveen

Rank: Advanced Member

Groups: Registered, Registered Users
Joined: 10/15/2005(UTC)
Posts: 31
Location: The Netherlands

Yes i've noticed that. The system tester returned very nice results, so i allready suspected that something wasn't right. Is there are a way to solve that problem?
Jose  
#44 Posted : Sunday, March 26, 2006 12:47:31 AM(UTC)
Jose

Rank: Advanced Member

Groups: Registered, Registered Users
Joined: 1/19/2005(UTC)
Posts: 1,065
Location: Koh Pha-Ngan, Earth

Was thanked: 2 time(s) in 2 post(s)
The solution is to avoid the use of any hindsight-based formulae, such as ZigZag, Peak(), Trough(), Ref(array,+x), LastValue(), Correl(), etc. For example, the MACDH Divergence kit doesn't use any hindsight-based functions, so its signals are always valid. jose '-)
billtrudeau  
#45 Posted : Thursday, September 28, 2006 8:10:51 PM(UTC)
billtrudeau

Rank: Advanced Member

Groups: Registered, Registered Users, Unverified Users
Joined: 4/27/2005(UTC)
Posts: 132
Location: Manchester, NH

I have added the Global Variable, but I get error messages in each of the formulas, such as "Does not contain an executable formula" or "variable does not exist in referenced formula"

I am looking for direction on the limits of the use of formula variable call and global variable. I have the content of everything that I am trying to accomplish with this formula but am fumbling along with the MS language as it applies to my formula. The formula primer does not give much detail or limits on use of some of the functions.

Any direction would be appreciated.

MetaStock -> Tools -> Indicator Builder -> New ->
Copy and paste complete formulae between "---8<---" lines.


===============================.
Ultimate Oscillator Divergence Buy Low
===============================
---8<------------------------------------

{Ultimate Oscillator Divergence Buy Low }
{ Note: first trough is dynamic }

{ User inputs }
TrPer:=Input("Trough %",0,100,15);
pds1:=Input("Ultimate periods 1",1,260,7);
pds2:=Input("Ultimate periods 2",1,260,14);
pds3:=Input("Ultimate periods 3",1,260,28);

A:=ExtFml("GV.SetVar","TrPer",TrPer);

{ Variables }
x:=Ult(pds1,pds2,pds3);
tr1:=Trough(1,x,TrPer);
tr2:=Trough(2,x,TrPer);
tr3:=Trough(3,x,TrPer);
tr4:=Trough(4,x,TrPer);
tr5:=Trough(5,x,TrPer);
tr6:=Trough(6,x,TrPer);
tr7:=Trough(7,x,TrPer);
tr8:=Trough(8,x,TrPer);
trLo:=ValueWhen(1,tr1<>Ref(tr1,-1),L);

A:=ExtFml("GV.SetVar","x",x);
A:=ExtFml("GV.SetVar","tr1",tr1);
A:=ExtFml("GV.SetVar","tr2",tr2);
A:=ExtFml("GV.SetVar","tr3",tr3);
A:=ExtFml("GV.SetVar","tr4",tr4);
A:=ExtFml("GV.SetVar","tr5",tr5);
A:=ExtFml("GV.SetVar","tr6",tr6);
A:=ExtFml("GV.SetVar","tr7",tr7);
A:=ExtFml("GV.SetVar","tr8",tr8);
A:=ExtFml("GV.SetVar","trLo",trLo);

{ Condition }
buy:=
x<Mov(x,9,E) AND x<50 AND

((tr1>tr2
AND tr2<>Ref(tr2,-1)
AND trLo<ValueWhen(2,tr2<>Ref(tr2,-1),L)

OR (tr1>tr3
AND tr3<>Ref(tr3,-1)
AND trLo<ValueWhen(3,tr3<>Ref(tr3,-1),L)
{Add condition that slope of tr3 to trLo is steeper than slope of tr2 to trLo and
slope of price L at tr3 to price L at trLo is flatter than slope of price at tr2
to price L at trLo}
AND FmlVar("Div SLP","slpt3")
AND FmlVar("Div SLP","slpl3"))

OR (tr1>tr4
AND tr4<>Ref(tr4,-1)
AND trLo<ValueWhen(4,tr4<>Ref(tr4,-1),L)
{Add condition that slope of tr4 to trLo is steeper than all previous slopes and
slope of price L at tr4 to price L at trLo is flatter than all previous slopes}
AND fmlvar("Div SLP","slpt4")
AND fmlvar("Div SLP","slpl4"))

OR (tr1>tr5
AND tr5<>Ref(tr5,-1)
AND trLo<ValueWhen(5,tr5<>Ref(tr5,-1),L)
{Add condition similar to previous}
AND fmlvar("Div SLP","slpt5")
AND fmlvar("Div SLP","slpl5"))

OR (tr1>tr6
AND tr6<>Ref(tr6,-1)
AND trLo<ValueWhen(6,tr6<>Ref(tr6,-1),L)
{Add condition similar to previous}
AND fmlvar("Div SLP","slpt6")
AND fmlvar("Div SLP","slpl6"))

OR (tr1>tr7
AND tr7<>Ref(tr7,-1)
AND trLo<ValueWhen(7,tr7<>Ref(tr7,-1),L)
{Add condition similar to previous}
AND fmlvar("Div SLP","slpt7")
AND fmlvar("Div SLP","slpl7"))

OR (tr1>tr8
AND tr8<>Ref(tr8,-1)
AND trLo<ValueWhen(8,tr8<>Ref(tr8,-1),L))
{Add condition similar to previous}
AND fmlvar("Div SLP","slpt8")
AND fmlvar("Div SLP","slpl8")));

{ Plot Long divergence signals in own window }
-buy

---8<------------------------------------
===============================.
Div TB
===============================
---8<------------------------------------

{ Determine number of bars since indicated trough}

x:=ExtFml("GV.GetVar","x");
TrPer:=ExtFml("GV.GetVar","TrPer");

tb1:= TroughBars(1,x,TrPer);
tb2:= TroughBars(2,x,TrPer);
tb3:= TroughBars(3,x,TrPer);
tb4:= TroughBars(4,x,TrPer);
tb5:= TroughBars(5,x,TrPer);
tb6:= TroughBars(6,x,TrPer);
tb7:= TroughBars(7,x,TrPer);
tb8:= TroughBars(8,x,TrPer);

---8<------------------------------------
===============================.
Div TLS
===============================
---8<------------------------------------

{ Determine slope of line connecting referenced indicator trough to most recent trough}

tr1:=ExtFml("GV.GetVar","tr1");
trLo:=ExtFml("GV.GetVar","trLo");
tr2:=ExtFml("GV.GetVar","tr2");
tr3:=ExtFml("GV.GetVar","tr3");
tr4:=ExtFml("GV.GetVar","tr4");
tr5:=ExtFml("GV.GetVar","tr5");
tr6:=ExtFml("GV.GetVar","tr6");
tr7:=ExtFml("GV.GetVar","tr7");
tr8:=ExtFml("GV.GetVar","tr8");
tb1:=fmlvar("Div TB","tb1");

slpt21:=(tr2- tr1)/( fmlvar("Div TB","tb2")-tb1);
slpt31:=(tr3- tr1)/( fmlvar("Div TB","tb3")-tb1);
slpt41:=(tr4- tr1)/( fmlvar("Div TB","tb4")-tb1);
slpt51:=(tr5- tr1)/( fmlvar("Div TB","tb5")-tb1);
slpt61:=(tr6- tr1)/( fmlvar("Div TB","tb6")-tb1);
slpt71:=(tr7- tr1)/( fmlvar("Div TB","tb7")-tb1);
slpt81:=(tr8- tr1)/( fmlvar("Div TB","tb8")-tb1);

{ Determine slope of price lows corresponding to indicator trough}

slpl21:=-(ValueWhen(2, tr1<>Ref(tr1,-1),L)-trLo)/( fmlvar("Div TB","tb2")-tb1);
slpl31:=-(ValueWhen(3, tr1<>Ref(tr1,-1),L)-trLo)/( fmlvar("Div TB","tb3")-tb1);
slpl41:=-(ValueWhen(4, tr1<>Ref(tr1,-1),L)-trLo)/( fmlvar("Div TB","tb4")-tb1);
slpl51:=-(ValueWhen(5, tr1<>Ref(tr1,-1),L)-trLo)/( fmlvar("Div TB","tb5")-tb1);
slpl61:=-(ValueWhen(6, tr1<>Ref(tr1,-1),L)-trLo)/( fmlvar("Div TB","tb6")-tb1);
slpl71:=-(ValueWhen(7, tr1<>Ref(tr1,-1),L)-trLo)/( fmlvar("Div TB","tb7")-tb1);
slpl81:=-(ValueWhen(8, tr1<>Ref(tr1,-1),L)-trLo)/( fmlvar("Div TB","tb8")-tb1);

---8<------------------------------------

===============================.
Div SLP
===============================
---8<------------------------------------

slpt3:= fmlvar("Div TLS","slpt31")>= fmlvar("Div TLS","slpt21");
slpt4:= fmlvar("Div TLS","slpt41")>= (fmlvar("Div TLS","slpt31") AND fmlvar("Div TLS","slpt21"));
slpt5:= fmlvar("Div TLS","slpt51")>= (fmlvar("Div TLS","slpt41") AND fmlvar("Div TLS","slpt31") AND fmlvar("Div TLS","slpt21"));
slpt6:= fmlvar("Div TLS","slpt61")>= (fmlvar("Div TLS","slpt51") AND fmlvar("Div TLS","slpt41") AND fmlvar("Div TLS","slpt31") AND fmlvar("Div TLS","slpt21"));
slpt7:= fmlvar("Div TLS","slpt71")>= (fmlvar("Div TLS","slpt61") AND fmlvar("Div TLS","slpt51") AND fmlvar("Div TLS","slpt41") AND fmlvar("Div TLS","slpt31") AND fmlvar("Div TLS","slpt21"));
slpt8:= fmlvar("Div TLS","slpt81")>= (fmlvar("Div TLS","slpt71") AND fmlvar("Div TLS","slpt61") AND fmlvar("Div TLS","slpt51") AND fmlvar("Div TLS","slpt41") AND fmlvar("Div TLS","slpt31") AND fmlvar("Div TLS","slpt21"));

slpl3:= fmlvar("Div TLS","slpl31")>= fmlvar("Div TLS","slpl21");
slpl4:= fmlvar("Div TLS","slpl41")>= (fmlvar("Div TLS","slpl31") AND fmlvar("Div TLS","slpl21"));
slpl5:= fmlvar("Div TLS","slpl51")>= (fmlvar("Div TLS","slpl41") AND fmlvar("Div TLS","slpl31") AND fmlvar("Div TLS","slpl21"));
slpl6:= fmlvar("Div TLS","slpl61")>= (fmlvar("Div TLS","slpl51") AND fmlvar("Div TLS","slpl41") AND fmlvar("Div TLS","slpl31") AND fmlvar("Div TLS","slpl21"));
slpl7:= fmlvar("Div TLS","slpl71")>= (fmlvar("Div TLS","slpl61") AND fmlvar("Div TLS","slpl51") AND fmlvar("Div TLS","slpl41") AND fmlvar("Div TLS","slpl31") AND fmlvar("Div TLS","slpl21"));
slpl8:= fmlvar("Div TLS","slpl81")>= (fmlvar("Div TLS","slpl71") AND fmlvar("Div TLS","slpl61") AND fmlvar("Div TLS","slpl51") AND fmlvar("Div TLS","slpl41") AND fmlvar("Div TLS","slpl31") AND fmlvar("Div TLS","slpl21"));

---8<------------------------------------

Jose  
#46 Posted : Friday, September 29, 2006 6:20:20 PM(UTC)
Jose

Rank: Advanced Member

Groups: Registered, Registered Users
Joined: 1/19/2005(UTC)
Posts: 1,065
Location: Koh Pha-Ngan, Earth

Was thanked: 2 time(s) in 2 post(s)
Of interest to members following this topic may be the new All-In-One Divergence module, which is included free with the MACDH Divergence kit. The All-In-One Divergence module includes 14 divergence indicators and 8 divergence types, for a total combination of 112 types of divergence signals. Client feedback reports point to the Momentum Histogram in conjunction with Standard & Hidden divergence as a promising combination. jose '-)
Users browsing this topic
Guest (Hidden)
3 Pages<123
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.