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:38:22 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)

Domenico D'Errico's article, “Detecting Swings”, presented a four trading strategies for swing trading. Below are the MetaStock formulas for these strategies: 

Strategy 1 (Pivot High-Low): 

Buy Long formula: 

Code:
el:= Ref(H, -1) > Max( H, Ref(H, -2));
es:= Ref(L, -1) < Min( L, Ref(L, -2));
ltrade:= If(PREV<=0, If(el, 1, 0),If(es OR (BarsSince(PREV<=0)>=4), -1, PREV));
ltrade = 1 and Ref( ltrade <= 0, -1)

Sell formula: 

Code:
el:= Ref(H, -1) > Max( H, Ref(H, -2));
es:= Ref(L, -1) < Min( L, Ref(L, -2));
ltrade:= If(PREV<=0, If(el, 1, 0),If(es OR (BarsSince(PREV<=0)>=4), -1, PREV));
ltrade = -1

Sell Short formula: 

Code:
el:= Ref(H, -1) > Max( H, Ref(H, -2));
es:= Ref(L, -1) < Min( L, Ref(L, -2));
strade:= If(PREV<=0, If(es, 1, 0),If(el OR (BarsSince(PREV<=0)>=4), -1, PREV));
strade = 1 and Ref( strade <= 0, -1)

Buy to Cover formula: 

Code:
el:= Ref(H, -1) > Max( H, Ref(H, -2));
es:= Ref(L, -1) < Min( L, Ref(L, -2));
strade:= If(PREV<=0, If(es, 1, 0),If(el OR (BarsSince(PREV<=0)>=4), -1, PREV));
strade = -1

Strategy 2 (Bollinger Bands): 

Buy Long formula: 

Code:
el:= Cross( C, BBandBot(C, 20, S, 2));
es:= Cross( BBandTop(C, 20, S, 2), C);
ltrade:= If(PREV<=0, If(el, 1, 0),If(es OR (BarsSince(PREV<=0)>=4), -1, PREV));
ltrade = 1 and Ref( ltrade <= 0, -1)

Sell formula: 

Code:
el:= Cross( C, BBandBot(C, 20, S, 2));
es:= Cross( BBandTop(C, 20, S, 2), C);
ltrade:= If(PREV<=0, If(el, 1, 0),If(es OR (BarsSince(PREV<=0)>=4), -1, PREV));
ltrade = -1

Sell Short formula: 

Code:
el:= Cross( C, BBandBot(C, 20, S, 2));
es:= Cross( BBandTop(C, 20, S, 2), C);
strade:= If(PREV<=0, If(es, 1, 0),If(el OR (BarsSince(PREV<=0)>=4), -1, PREV));
strade = 1 and Ref( strade <= 0, -1)

Buy to Cover formula: 

Code:
el:= Cross( C, BBandBot(C, 20, S, 2));
es:= Cross( BBandTop(C, 20, S, 2), C);
strade:= If(PREV<=0, If(es, 1, 0),If(el OR (BarsSince(PREV<=0)>=4), -1, PREV));
strade = -1

Strategy 3 (RSI Cross): 

Buy Long formula: 

Code:
el:= Cross( RSI(5), 40);
es:= Cross( 60, RSI(5));
ltrade:= If(PREV<=0, If(el, 1, 0),If(es OR (BarsSince(PREV<=0)>=4), -1, PREV));
ltrade = 1 and Ref( ltrade <= 0, -1)

Sell formula: 

Code:
el:= Cross( RSI(5), 40);
es:= Cross( 60, RSI(5));
ltrade:= If(PREV<=0, If(el, 1, 0),If(es OR (BarsSince(PREV<=0)>=4), -1, PREV));
ltrade = -1

Sell Short formula: 

Code:
el:= Cross( RSI(5), 40);
es:= Cross( 60, RSI(5));
strade:= If(PREV<=0, If(es, 1, 0),If(el OR (BarsSince(PREV<=0)>=4), -1, PREV));
strade = 1 and Ref( strade <= 0, -1)

Buy to Cover formula: 

Code:
el:= Cross( RSI(5), 40);
es:= Cross( 60, RSI(5));
strade:= If(PREV<=0, If(es, 1, 0),If(el OR (BarsSince(PREV<=0)>=4), -1, PREV));
strade = -1

Strategy 4 (RSI & higher Low / lower High): 

Buy Long formula: 

Code:
el:= RSI(5) < 40 AND L > Ref(L, -1);
es:= RSI(5) > 60 AND H < Ref(H, -1);
ltrade:= If(PREV<=0, If(el, 1, 0),If(es OR (BarsSince(PREV<=0)>=4), -1, PREV));
ltrade = 1 and Ref( ltrade <= 0, -1)

Sell formula: 

Code:
el:= RSI(5) < 40 AND L > Ref(L, -1);
es:= RSI(5) > 60 AND H < Ref(H, -1);
ltrade:= If(PREV<=0, If(el, 1, 0),If(es OR (BarsSince(PREV<=0)>=4), -1, PREV));
ltrade = -1

Sell Short formula: 

Code:
el:= RSI(5) < 40 AND L > Ref(L, -1);
es:= RSI(5) > 60 AND H < Ref(H, -1);
strade:= If(PREV<=0, If(es, 1, 0),If(el OR (BarsSince(PREV<=0)>=4), -1, PREV));
strade = 1 and Ref( strade <= 0, -1)

Buy to Cover formula: 

Code:
el:= RSI(5) < 40 AND L > Ref(L, -1);
es:= RSI(5) > 60 AND H < Ref(H, -1);
strade:= If(PREV<=0, If(es, 1, 0),If(el OR (BarsSince(PREV<=0)>=4), -1, PREV));
strade = -1

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.