Rank: Advanced Member
Groups: Registered, Registered Users, Unverified Users Joined: 4/27/2005(UTC) Posts: 132 Location: Manchester, NH
|
I have broken the formula into three formulas. However, the first formula is still to big. There is a limit of 2500 characters per formula, which includes spaces. In order to evaluate if I can delete spaces, I need to know what MS considers a space. Is a space just the space between characters, or does it count a blank line as so many blank spaces and does it assign blank spaces to the remainder of a line when using carriage returns? Based upon the number of characters and spaces between the characters, I think that I should be well below the limit. However, I will confess that I did not try to count all 2500 characters.
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 );
{ 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);
{ 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 TLS”,”slpt31”)>= fmlvar(“Div TLS”,”slpt21”)
AND fmlvar(“Div TLS”,”slpl31”)>= fmlvar(“Div TLS”,”slpl21”)
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 TLS”,”slpt41”)>= (fmlvar(“Div TLS”,”slpt31”) AND fmlvar(“Div TLS”,”slpt21”))
AND fmlvar(“Div TLS”,”slpl41”)>= (fmlvar(“Div TLS”,”slpl31”) AND fmlvar(“Div TLS”,”slpl21”))
OR tr1>tr5
AND tr5<>Ref(tr5,-1)
AND trLo<ValueWhen(5,tr5<>Ref(tr5,-1),L)
{Add condition that slope of tr5 to trLo is steeper than all previous slopes and
slope of price L at tr5 to price L at trLo is flatter than all previous slopes}
AND fmlvar(“Div TLS”,”slpt51”)>= (fmlvar(“Div TLS”,”slpt41”) AND fmlvar(“Div TLS”,”slpt31”) AND fmlvar(“Div TLS”,”slpt21”))
AND fmlvar(“Div TLS”,”slpl51”)>= (fmlvar(“Div TLS”,”slpl41”) AND fmlvar(“Div TLS”,”slpl31”) AND fmlvar(“Div TLS”,”slpl21”))
OR tr1>tr6
AND tr6<>Ref(tr6,-1)
AND trLo<ValueWhen(6,tr6<>Ref(tr6,-1),L)
{Add condition that slope of tr6 to trLo is steeper than all previous slopes and
slope of price L at tr6 to price L at trLo is flatter than all previous slopes}
AND fmlvar(“Div TLS”,”slpt61”)>= (fmlvar(“Div TLS”,”slpt51”) AND fmlvar(“Div TLS”,”slpt41”) AND fmlvar(“Div TLS”,”slpt31”) AND fmlvar(“Div TLS”,”slpt21”))
AND fmlvar(“Div TLS”,”slpl61”)>= (fmlvar(“Div TLS”,”slpl51”) AND fmlvar(“Div TLS”,”slpl41”) AND fmlvar(“Div TLS”,”slpl31”) AND fmlvar(“Div TLS”,”slpl21”))
OR tr1>tr7
AND tr7<>Ref(tr7,-1)
AND trLo<ValueWhen(7,tr7<>Ref(tr7,-1),L)
{Add condition that slope of tr7 to trLo is steeper than all previous slopes and
slope of price L at tr7 to price L at trLo is flatter than all previous slopes}
AND 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”))
AND 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”))
OR tr1>tr8
AND tr8<>Ref(tr8,-1)
AND trLo<ValueWhen(8,tr8<>Ref(tr8,-1),L))
{Add condition that slope of tr8 to trLo is steeper than all previous slopes and
slope of price L at tr8 to price L at trLo is flatter than all previous slopes}
AND 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”))
AND 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”));
{ Plot Long divergence signals in own window }
-buy
---8<------------------------------------
===============================.
Div TB
===============================
---8<------------------------------------
{ Determine number of bars since indicated trough}
x:=fmlvar(“Ultimate Oscillator Divergence Buy Low”,”x”);
tb1:= TroughBars(1,x, fmlvar(” Ultimate Oscillator Divergence Buy Low”,”TrPer”));
tb2:= TroughBars(2,x, fmlvar(” Ultimate Oscillator Divergence Buy Low”,”TrPer”));
tb3:= TroughBars(3,x, fmlvar(” Ultimate Oscillator Divergence Buy Low”,”TrPer”));
tb4:= TroughBars(4,x, fmlvar(” Ultimate Oscillator Divergence Buy Low”,”TrPer”));
tb5:= TroughBars(5,x, fmlvar(” Ultimate Oscillator Divergence Buy Low”,”TrPer”));
tb6:= TroughBars(6,x, fmlvar(” Ultimate Oscillator Divergence Buy Low”,”TrPer”));
tb7:= TroughBars(7,x, fmlvar(” Ultimate Oscillator Divergence Buy Low”,”TrPer”));
tb8:= TroughBars(8,x, fmlvar(” Ultimate Oscillator Divergence Buy Low”,”TrPer”));
---8<------------------------------------
|