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

Notification

Icon
Error

Options
Go to last post Go to first unread
MS Support  
#1 Posted : Friday, July 28, 2017 10:50:25 PM(UTC)
MS Support

Rank: Advanced Member

Groups: Moderators, Registered, Registered Users, Subscribers
Joined: 10/8/2010(UTC)
Posts: 1,960

Thanks: 92 times
Was thanked: 155 time(s) in 150 post(s)

Markos Katsanos' article, “Trading the Nikkei”, presented his system for correlating currency against market strength. The formulas for implementing this system in MetaStock are listed below. Due to the complexity of the formulas, two helper formulas must be created first before the trade signal formulas can be written.

The entry and exit signal formula have values set for the stop percentage and length of the trades. If you wish to use different values, you must change those number in both the entry and the exit signal or the signals will not correctly align.

Indicators:

Code:
- ?DXJ System CR2 helper

s1:= Security("ONLINE:FXY", C); D1:= 50; RS1:= (C/Ref(C, -D1) -1)*100; RS2:= (s1/Ref(s1, -D1) -1)*100; Q1:= Sum((RS1*RS2), D1)- ((Sum(RS1,D1)*Sum(RS2,D1))/D1); Q2:= Sum((RS2*RS2), D1)- ((Sum(RS2,D1)*Sum(RS2,D1))/D1); Q3:= Sum((RS1*RS1), D1)- ((Sum(RS1,D1)*Sum(RS1,D1))/D1); Q2Q3:= If(Q2 * Q3 > 0, Sqrt(If(Q2=0, 1, Abs(Q2))*If(Q3=0, 1, Abs(Q3))), -1); R:= If(Q2Q3 = -1, 0, Q1/Q2Q3); If(R<-1, -1, If(R > 1, 1, R))

Code:
- ?DXJ System CR3 helper

s1:= Security("ONLINE:SPY", C); D1:= 50; RS1:= (C/Ref(C, -D1) -1)*100; RS2:= (s1/Ref(s1, -D1) -1)*100; Q1:= Sum((RS1*RS2), D1)- ((Sum(RS1,D1)*Sum(RS2,D1))/D1); Q2:= Sum((RS2*RS2), D1)- ((Sum(RS2,D1)*Sum(RS2,D1))/D1); Q3:= Sum((RS1*RS1), D1)- ((Sum(RS1,D1)*Sum(RS1,D1))/D1); Q2Q3:= If(Q2 * Q3 > 0, Sqrt(If(Q2=0, 1, Abs(Q2))*If(Q3=0, 1, Abs(Q3))), -1); R:= If(Q2Q3 = -1, 0, Q1/Q2Q3); If(R<-1, -1, If(R > 1, 1, R))

Trading Signals:

Enter Long:

Code:
s1:= Security("ONLINE:FXY", C);
stp:= 1.5; {Stop Percentage}
exit:= 11; {Maximum bars in trade}
stoc:= (Mov(C-LLV(L,25),3,S)*100)/Mov(HHV(H,25)-LLV(L,25),3,S);
LR:= 100*LinRegSlope(C, 25);
RS1:= (C/Ref(C, -3) -1)*100;
RS2:= (s1/Ref(s1, -3) -1)*100;
CR2:= Fml("- ?DXJ System CR2 helper");
CR3:= Fml("- ?DXJ System CR3 helper");
b2:= CR2*Stdev(RS1, 50)/Stdev(RS2,50) + 0.001;
a2:= Mov(RS2, 50, S)- b2*Mov(RS2,50,S);
pred2:= b2*RS2+a2;
div2:= pred2-RS1;
IM2:= (Mov(div2-LLV(div2,50),2,S)*100)/
(Mov(HHV(div2,50)-LLV(div2,50),2,S)+.01);
lstop:= 1- stp/100;
el:= Ref(IM2,-3)>75 AND IM2<Ref(IM2,-3) AND IM2>25 AND
CR3<0.8 AND (LR>= Ref(LR,-1) OR C>Mov(C,25,S));
ltrade:= If(PREV<=0, If(el, C, 0),
If(BarsSince(PREV<=0)>3 AND C < PREV*lstop, -1,
If(BarsSince(PREV<=0)>7 AND C < HighestSince(1, PREV<=0, C*lstop), -2,
If(BarsSince(PREV<=0)>=exit, -3, PREV))));
ltrade>0 AND Ref(ltrade<=0, -1)

Exit Long:

Code:
s1:= Security("ONLINE:FXY", C);
stp:= 1.5; {Stop Percentage}
exit:= 11; {Maximum bars in trade}
stoc:= (Mov(C-LLV(L,25),3,S)*100)/Mov(HHV(H,25)-LLV(L,25),3,S);
LR:= 100*LinRegSlope(C, 25);
RS1:= (C/Ref(C, -3) -1)*100;
RS2:= (s1/Ref(s1, -3) -1)*100;
CR2:= Fml("- ?DXJ System CR2 helper");
CR3:= Fml("- ?DXJ System CR3 helper");
b2:= CR2*Stdev(RS1, 50)/Stdev(RS2,50) + 0.001;
a2:= Mov(RS2, 50, S)- b2*Mov(RS2,50,S);
pred2:= b2*RS2+a2;
div2:= pred2-RS1;
IM2:= (Mov(div2-LLV(div2,50),2,S)*100)/
(Mov(HHV(div2,50)-LLV(div2,50),2,S)+.01);
lstop:= 1- stp/100;
el:= Ref(IM2,-3)>75 AND IM2<Ref(IM2,-3) AND IM2>25 AND
CR3<0.8 AND (LR>= Ref(LR,-1) OR C>Mov(C,25,S));
ltrade:= If(PREV<=0, If(el, C, 0),
If(BarsSince(PREV<=0)>3 AND C < PREV*lstop, -1,
If(BarsSince(PREV<=0)>7 AND C < HighestSince(1, PREV<=0, C*lstop), -2,
If(BarsSince(PREV<=0)>=exit, -3, PREV))));
ltrade<0

Enter Short:

Code:
s1:= Security("ONLINE:FXY", C);
stp:= 1.5; {Stop Percentage}
exit:= 11; {Maximum bars in trade}
stoc:= (Mov(C-LLV(L,25),3,S)*100)/Mov(HHV(H,25)-LLV(L,25),3,S);
LR:= 100*LinRegSlope(C, 25);
RS1:= (C/Ref(C, -3) -1)*100;
RS2:= (s1/Ref(s1, -3) -1)*100;
CR2:= Fml("- ?DXJ System CR2 helper");
CR3:= Fml("- ?DXJ System CR3 helper");
b2:= CR2*Stdev(RS1, 50)/Stdev(RS2,50) + 0.001;
a2:= Mov(RS2, 50, S)- b2*Mov(RS2,50,S);
pred2:= b2*RS2+a2;
div2:= pred2-RS1;
IM2:= (Mov(div2-LLV(div2,50),2,S)*100)/
(Mov(HHV(div2,50)-LLV(div2,50),2,S)+.01);
sstop:= 1+ stp/100;
es:= Ref(IM2,-3)<25 AND IM2>Ref(IM2,-3) AND IM2<75 AND
CR3<0.8 AND (LR<=Ref(LR,-1) OR C<Mov(C,25,S));
strade:= If(PREV<=0, If(es, C, 0),
If(BarsSince(PREV<=0)>3 AND C > PREV*sstop, -1,
If(BarsSince(PREV<=0)>7 AND C > LowestSince(1, PREV<=0, C*sstop), -2,
If(BarsSince(PREV<=0)>=exit, -3, PREV))));
strade>0 AND Ref(strade<=0, -1)

Exit Short:

Code:
s1:= Security("ONLINE:FXY", C);
stp:= 1.5; {Stop Percentage}
exit:= 11; {Maximum bars in trade}
stoc:= (Mov(C-LLV(L,25),3,S)*100)/Mov(HHV(H,25)-LLV(L,25),3,S);
LR:= 100*LinRegSlope(C, 25);
RS1:= (C/Ref(C, -3) -1)*100;
RS2:= (s1/Ref(s1, -3) -1)*100;
CR2:= Fml("- ?DXJ System CR2 helper");
CR3:= Fml("- ?DXJ System CR3 helper");
b2:= CR2*Stdev(RS1, 50)/Stdev(RS2,50) + 0.001;
a2:= Mov(RS2, 50, S)- b2*Mov(RS2,50,S);
pred2:= b2*RS2+a2;
div2:= pred2-RS1;
IM2:= (Mov(div2-LLV(div2,50),2,S)*100)/
(Mov(HHV(div2,50)-LLV(div2,50),2,S)+.01);
sstop:= 1+ stp/100;
es:= Ref(IM2,-3)<25 AND IM2>Ref(IM2,-3) AND IM2<75 AND
CR3<0.8 AND (LR<=Ref(LR,-1) OR C<Mov(C,25,S));
strade:= If(PREV<=0, If(es, C, 0),
If(BarsSince(PREV<=0)>3 AND C > PREV*sstop, -1,
If(BarsSince(PREV<=0)>7 AND C > LowestSince(1, PREV<=0, C*sstop), -2,
If(BarsSince(PREV<=0)>=exit, -3, PREV))));
strade<0

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.