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

### Notification

Error

 New Topic Post Reply
 Previous Topic Next Topic
 MS Support #1 Posted : Friday, July 28, 2017 10:38:22 PM(UTC) Quote Multi-Quote Rank: Advanced MemberGroups: Moderators, Registered, Registered Users, SubscribersJoined: 10/8/2010(UTC)Posts: 1,372Thanks: 28 timesWas thanked: 104 time(s) in 101 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``````
 Wanna join the discussion?! Login to your Discussions forum accountor Register a new forum account.
 Users browsing this topic
 New Topic Post Reply
Forum Jump
You can post new topics in this forum.
You can reply to topics in this forum.
You can delete your posts in this forum.
You can edit your posts in this forum.
You cannot create polls in this forum.
You can vote in polls in this forum.