BullCharts Forum Homepage
Forum Home Forum Home > BullCharts > BullScript
  New Posts New Posts RSS Feed: Metastock swing indicator.
  FAQ FAQ  Forum Search   Calendar   Register Register  Login Login

Metastock swing indicator.

 Post Reply Post Reply Page  12>
Author
Message / View First Unread Post
charlie_8 View Drop Down
Regular
Regular


Joined: 06 Apr 2011
Posts: 21
Post Options Post Options   Quote charlie_8 Quote  Post ReplyReply Direct Link To This Post Topic: Metastock swing indicator.
    Posted: 12 Apr 2011 at 9:10am
hi to all bs forum members,

i`m pretty new at BS. I have a swing indicator formula, that I often use in MS. could somebody help me to convert these 2 formulae in bullscript?

SWING REVERSAL UP
m1:= H<Ref(H,-1) AND L<Ref(L,-1);
m2:= H<Ref(H,-2) AND L<Ref(L,-2) AND
H>Ref(H,-1)AND L<Ref(L,-1);
m3:=H<Ref(H,-3) AND L<Ref(L,-3) AND
H>Ref(H,-2) AND L<Ref(L,-2) AND
H>Ref(H,-1) AND L<Ref(L,-1);
mark:= m1 OR m2 OR m3;
set:=L >ValueWhen(1,mark,L) AND H>ValueWhen(1,mark,H) AND
LowestSince(1,Ref(mark,-1),L) > ValueWhen(1,mark,L);
sig:= If(mark,1, If(set,0,PREV));
Cross(sig=0,0.5)

SWING REVERSAL DOWN
m1:= H>Ref(H,-1) AND L>Ref(L,-1);
m2:= H>Ref(H,-2) AND L>Ref(L,-2) AND
H>Ref(H,-1) AND L<Ref(L,-1);
m3:= H>Ref(H,-3) AND L>Ref(L,-3) AND
H>Ref(H,-2) AND L<Ref(L,-2) AND
H>Ref(H,-1) AND L<Ref(L,-1);
mark:= m1 OR m2 OR m3;
set:=L<ValueWhen(1,mark,L) AND H<ValueWhen(1,mark,H) AND
HighestSince(1,Ref(mark,-1) , H) < ValueWhen(1,mark,H);
sig:= If(mark,1, If(set, 0, PREV)); 
Cross(sig=0,0.5)

Thank you :)
Back to Top
maximo View Drop Down
BullCharts Guru
BullCharts Guru
Avatar

Joined: 02 Sep 2006
Location: Australia
Posts: 232
Post Options Post Options   Quote maximo Quote  Post ReplyReply Direct Link To This Post Posted: 13 Apr 2011 at 12:26am
hey charlie
 
Looks good on weekly charts like MMS. Add medium to long average, trading only in direction of that larger trend.
 
 
{ SWING REVERSAL UP }
[target=price]
m1:= H<Ref(H,-1) AND L<Ref(L,-1);
m2:= H<Ref(H,-2) AND L<Ref(L,-2) AND H>Ref(H,-1)AND L<Ref(L,-1);
m3:=H<Ref(H,-3) AND L<Ref(L,-3) AND H>Ref(H,-2) AND L<Ref(L,-2) AND H>Ref(H,-1) AND L<Ref(L,-1);
mark:= m1 OR m2 OR m3;
set:=L >ValueWhen(1,mark,L) AND H>ValueWhen(1,mark,H) AND LowestSince(1,Ref(mark,-1),L) > ValueWhen(1,mark,L);
sig:= If(mark,1, If(set,0,PREV));
[name=Up; linestyle=marker; marker=type1;]
SWRup:=Cross(sig=0,0.5);
SWRup

 
{ SWING REVERSAL DOWN }
[target=price]
m1:= H>Ref(H,-1) AND L>Ref(L,-1);
m2:= H>Ref(H,-2) AND L>Ref(L,-2) AND H>Ref(H,-1) AND L<Ref(L,-1);
m3:= H>Ref(H,-3) AND L>Ref(L,-3) AND H>Ref(H,-2) AND L<Ref(L,-2) AND H>Ref(H,-1) AND L<Ref(L,-1);
mark:= m1 OR m2 OR m3;
set:=L<ValueWhen(1,mark,L) AND H<ValueWhen(1,mark,H) AND HighestSince(1,Ref(mark,-1) , H) < ValueWhen(1,mark,H);
sig:= If(mark,1, If(set, 0, PREV));
[name=Dwn; linestyle=marker; marker=type2;]
SWRdwn:=Cross(sig=0,0.5);
SWRdwn


Edited by maximo - 13 Apr 2011 at 12:27am
Back to Top
charlie_8 View Drop Down
Regular
Regular


Joined: 06 Apr 2011
Posts: 21
Post Options Post Options   Quote charlie_8 Quote  Post ReplyReply Direct Link To This Post Posted: 13 Apr 2011 at 12:43am
hey maximo,

thank you for recoding those indicators for BS. Those formulae both are from the book "Trading Triads" (the author is Felipe Tudela), that I bought some months ago.
Back to Top
charlie_8 View Drop Down
Regular
Regular


Joined: 06 Apr 2011
Posts: 21
Post Options Post Options   Quote charlie_8 Quote  Post ReplyReply Direct Link To This Post Posted: 13 Apr 2011 at 7:15am
I found that there are some much better ways to trade those swing reversals (triads), than to use any MAs or other tecnical indicators. I dont use them at all, I am more a price action guy :)

Edited by charlie_8 - 13 Apr 2011 at 7:49am
Back to Top
maximo View Drop Down
BullCharts Guru
BullCharts Guru
Avatar

Joined: 02 Sep 2006
Location: Australia
Posts: 232
Post Options Post Options   Quote maximo Quote  Post ReplyReply Direct Link To This Post Posted: 13 Apr 2011 at 4:52pm

Thanks for sharing those swing indicators charlie. The logic is sound and they can provide a statistical edge as part of a trading plan.  They are based on price action, so that would be of help to many out there looking at price action strategies, which work well in most markets.  I consider Darvas boxes another price action method, since they are not based on mathematical calculations.

 



Edited by maximo - 13 Apr 2011 at 4:54pm
Back to Top
charlie_8 View Drop Down
Regular
Regular


Joined: 06 Apr 2011
Posts: 21
Post Options Post Options   Quote charlie_8 Quote  Post ReplyReply Direct Link To This Post Posted: 03 May 2011 at 10:22am
Never say never ;) I found Hull 9/21 MAs very interesting for determination of the trend direction. Could you pleace write the ribbon for me, red for downtrend, blue for uptrent? The triads are looking very interesting with HMAs :)

Thank you!
Back to Top
maximo View Drop Down
BullCharts Guru
BullCharts Guru
Avatar

Joined: 02 Sep 2006
Location: Australia
Posts: 232
Post Options Post Options   Quote maximo Quote  Post ReplyReply Direct Link To This Post Posted: 05 May 2011 at 11:31am
Here's a ribbon for the Hull dual moving averages.
 
 
[Description="Hull-MA Dual Moving Average Ribbon"]
[target=ribbon]
per1:= input("Period1",9,1);
per2:= input("Period2",21,1);
ma1 := ma(2*ma(C,int(per1/2),W) - ma(C,per1,W),int(sqrt(per1)), W);
ma2 := ma(2*ma(C,int(per2/2),W) - ma(C,per2,W),int(sqrt(per2)), W);
[color=Blue; name=Above]
SignalAbove:= ref(ma1,1) >= ref(ma2,1);
SignalAbove;
[color=Red; name=Below]
SignalBelow:= ref(ma2,1) < ref(ma1,1);
SignalBelow;
 
 
Here are the same moving averages plotted on price
 
[Description="Hull-MA Dual Moving Averages"]
[target=price]
per1:= input("Period1",9,1);
per2:= input("Period2",21,1);
ma1 := ma(2*ma(C,int(per1/2),W) - ma(C,per1,W),int(sqrt(per1)), W);
ma2 := ma(2*ma(C,int(per2/2),W) - ma(C,per2,W),int(sqrt(per2)), W);
[color=Blue; name=Above]
ma1;
[color=Red; name=Below]
ma2;
 


Edited by maximo - 05 May 2011 at 11:32am
Back to Top
charlie_8 View Drop Down
Regular
Regular


Joined: 06 Apr 2011
Posts: 21
Post Options Post Options   Quote charlie_8 Quote  Post ReplyReply Direct Link To This Post Posted: 07 May 2011 at 12:34am
thank you very much maximo!
I found also that adding hma (50) hepls to filter out many bad trades, try it and I'll be happy if you like it.Smile
but i would never buy on close or on open of a next bar (how Tudela suggested), but only on breakout of the high of the bar.


Edited by charlie_8 - 07 May 2011 at 1:39am
Back to Top
cmacdon View Drop Down
BullCharts Guru
BullCharts Guru


Joined: 09 Sep 2012
Location: Brisbane
Posts: 236
Post Options Post Options   Quote cmacdon Quote  Post ReplyReply Direct Link To This Post Posted: 05 Apr 2014 at 12:18pm
I was retesting various fractal definitions to see if I could find an improvement on John Crane's action reaction pivot point method, and had another look at Tudela's Triad definition. (Triads are otherwise known as fractals or pivot points),    

The above post has some code named Metastock Swing indicator which in fact the Metastock code for his Tudela's Triad indicator provided in Metastock format on page 213 - 214 of Tudela's book quoted in citation below.

So it is not actually an indicator for a swing but the bar after a fractal or pivot point. I had previously color coded the fractal bars in Bullcharts when the book came out but I did not really find them useful at the time so stored the indicator away. But this time in playing around with the code I added two lines using Tudela's code and the additional lines now colour code the continuation or swing bars leading into and after his triad definitions so they show similar thing to resultant trend or swing as Tudela would define a Swing. The two extra lines are just adapting his original Triads So you can play around with this. There are black bars not colour coded and this seems to arise as they reflect inside bars or outside bars which Tudela's code does not deal with. I will post a chart and then the code so you can play around with it further
BC User since June 2007
Back to Top
cmacdon View Drop Down
BullCharts Guru
BullCharts Guru


Joined: 09 Sep 2012
Location: Brisbane
Posts: 236
Post Options Post Options   Quote cmacdon Quote  Post ReplyReply Direct Link To This Post Posted: 05 Apr 2014 at 12:38pm
Seems to be usual problem loading images so here is code:
[target=Price; linestyle=PriceColor]

[Citation= "Trading Triads Felipe Tudela, John Wiley & Sons, 2010, Metastock code on pp 213-214"]

{DESCENDING TRIAD}
m1:=H>Ref(H,-1) AND L>Ref(L,-1);
m2:=H>Ref(H,-1) AND L<Ref(L,-1) AND H>Ref(H,-2) AND L>Ref(L,-2);
m3:=H>Ref(H,-1) AND L<Ref(L,-1) AND H>Ref(H,-2) AND L<Ref(L,-2) AND H>Ref(H,-3) AND L>Ref(L,-3);

mark:=m1 OR m2 OR m3;
Set:=L<ValueWhen(1,mark,L) AND H<ValueWhen(1,mark,H) AND HighestSince(1,Ref(mark,-1),H)<ValueWhen(1,mark,H);

sig:=If(mark,1, If(Set,0,PREV));

[color=Red; name=DownTriad];[width=4];
Cross(sig=0,0.5);

{ASCENDING TRIAD}
a1:=H<Ref(H,-1) AND L<Ref(L,-1);
a2:=H<Ref(H,-2) AND L<Ref(L,-2) and H>Ref(H,-1) AND L<Ref(L,-1) ;
a3:=H<Ref(H,-3) AND L<Ref(L,-3) and H>Ref(H,-2) AND L<Ref(L,-2) and H>Ref(H,-1) AND L<Ref(L,-1) ;

amark:=a1 OR a2 OR a3;
aSet:=L>ValueWhen(1,amark,L) AND H>ValueWhen(1,amark,H) AND LowestSince(1,Ref(amark,-1),L)>ValueWhen(1,amark,L);

asig:=If(amark,1, If(aSet,0,PREV));

[color=Blue; name=UpTriad]; [width=4];
Cross(asig=0,0.5);


{These two lines added to show the continuation bars based on above formula subsequent to a Triad being formed as defined by Tudela}

[color=Orange; name=Subequent Down Swing];
If(amark=1,1, undefined);

[color=Light Sky Blue; name=Subsequent Up Swing];
If(mark=1,1, undefined);
BC User since June 2007
Back to Top
 Post Reply Post Reply Page  12>

Forum Jump Forum Permissions View Drop Down

Bulletin Board Software by Web Wiz Forums® version 9.69
Copyright ©2001-2010 Web Wiz