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

Notification

Icon
Error

Options
Go to last post Go to first unread
Damien  
#1 Posted : Friday, September 4, 2009 7:12:33 PM(UTC)
Damien

Rank: Member

Groups: Registered, Registered Users
Joined: 6/18/2009(UTC)
Posts: 15

Hello,

Could you please assist me with writng a custom indicator that will plot swing lines, with the following rules:

  1. Swing lines connect either Highs or Lows of individual bars - never Open or Close.
  2. If the next bar has a higher high and a higher low (or the same low) when compared to the previous bar, then the swing line goes up connecting the high of the next bar.
  3. If the next bar has a lower high (or same high) and a lower low when compared to the previous bar, then the swing line goes down connecting the low of the next bar.
  4. If the next bar is an inside bar (lower high and higher low), ignore it and don’t plot a line on it at all – wait for the next bar.
  5. If the next br is an outside bar (higher high and lower low), plot a swing line on the high of an outside bar if the following bar (one after the outside bar) is lower, OR plot a swing line on the low of an outside bar if the following bar (one after the outside bar) is higher.

Regards

Damien

johnl  
#2 Posted : Sunday, September 6, 2009 10:04:57 PM(UTC)
johnl

Rank: Advanced Member

Groups: Registered, Registered Users
Joined: 11/7/2005(UTC)
Posts: 602

a1:=If((H>Ref(H,-1) and (L>Ref(L,-1)),H,prev);
a2:=If((H<Ref(H,-1) and (L<Ref(L,-1)),L,prev);
Your #2 and #3 should look like this, from this code you should be able to work out the rest.

Damien  
#3 Posted : Monday, September 7, 2009 5:01:07 AM(UTC)
Damien

Rank: Member

Groups: Registered, Registered Users
Joined: 6/18/2009(UTC)
Posts: 15

Hi,

Thanks for this. It's not working. Would you pleasee write the complete formula so I could test it then?

Rgds

Damien

bobylam  
#4 Posted : Monday, September 7, 2009 5:44:11 AM(UTC)
bobylam

Rank: Member

Groups: Registered, Registered Users
Joined: 6/25/2009(UTC)
Posts: 10

maybe this is what john1 mean: just one more ")"

If((H>Ref(H,-1)) AND (L>Ref(L,-1)),H,PREV);
If((H<Ref(H,-1)) AND (L<Ref(L,-1)),L,PREV);
Damien  
#5 Posted : Monday, September 7, 2009 7:07:02 AM(UTC)
Damien

Rank: Member

Groups: Registered, Registered Users
Joined: 6/18/2009(UTC)
Posts: 15

Thanks. Now there is no error, but the formula has produced no result/swing line at all.

Rgds

Damien

bobylam  
#6 Posted : Monday, September 7, 2009 10:35:10 AM(UTC)
bobylam

Rank: Member

Groups: Registered, Registered Users
Joined: 6/25/2009(UTC)
Posts: 10

Damien wrote:

Thanks. Now there is no error, but the formula has produced no result/swing line at all.

Rgds

Damien



maybe this is what you most wanted :-)

a1:= If((H>Ref(H,-1)) AND (L>Ref(L,-1)),H,PREV);
a2:= If((H<Ref(H,-1)) AND (L<Ref(L,-1)),L,PREV);

If( a1<>Ref(a1,-1),a1,a2);
Damien  
#7 Posted : Tuesday, September 8, 2009 6:08:05 AM(UTC)
Damien

Rank: Member

Groups: Registered, Registered Users
Joined: 6/18/2009(UTC)
Posts: 15

Thanks.

I wanted to attach a screen shot of swing lines on a real chart....that would assist in the explanation what it should look like. Do you maybe have an email I could send you that?

Rgds

Damien

johnl  
#8 Posted : Tuesday, September 8, 2009 8:47:12 PM(UTC)
johnl

Rank: Advanced Member

Groups: Registered, Registered Users
Joined: 11/7/2005(UTC)
Posts: 602

The attachment didn't work Upload it to the internet and give us a link to the jpg.
Thanks.

Damien  
#9 Posted : Tuesday, September 8, 2009 11:21:08 PM(UTC)
Damien

Rank: Member

Groups: Registered, Registered Users
Joined: 6/18/2009(UTC)
Posts: 15

Where can I upload it?
bobylam  
#10 Posted : Wednesday, September 9, 2009 12:23:50 AM(UTC)
bobylam

Rank: Member

Groups: Registered, Registered Users
Joined: 6/25/2009(UTC)
Posts: 10

bobylam  
#11 Posted : Wednesday, September 9, 2009 12:34:37 AM(UTC)
bobylam

Rank: Member

Groups: Registered, Registered Users
Joined: 6/25/2009(UTC)
Posts: 10

Damien wrote:

Thanks. Now there is no error, but the formula has produced no result/swing line at all.

Rgds

Damien



this code worked, you can see sample with DJ


If((H>Ref(H,-1)) AND (L>Ref(L,-1)),H,PREV);
If((H<Ref(H,-1)) AND (L<Ref(L,-1)),L,PREV);

sample:

http://img193.imageshack.us/img193/4686/swinglines.png
Damien  
#12 Posted : Wednesday, September 9, 2009 12:55:34 AM(UTC)
Damien

Rank: Member

Groups: Registered, Registered Users
Joined: 6/18/2009(UTC)
Posts: 15

http://img179.imageshack.us/i/swingline.jpg/

If you go to the link above, you'll see what the swing lines should look like (in blue)...it's easier to understand it from a picture.

Rgds

Damien

johnl  
#13 Posted : Wednesday, September 9, 2009 8:54:18 PM(UTC)
johnl

Rank: Advanced Member

Groups: Registered, Registered Users
Joined: 11/7/2005(UTC)
Posts: 602

Thanks for the chart, much better.
Play around with-

a1:=Trough(2,C,5);
a1

It might be closer to what you are looking for.
Be careful with zigzag, the first zigzag is bogus.


Damien  
#14 Posted : Thursday, September 10, 2009 5:39:48 AM(UTC)
Damien

Rank: Member

Groups: Registered, Registered Users
Joined: 6/18/2009(UTC)
Posts: 15

Thanks. I tried, but it's just not working for me...
Asad  
#15 Posted : Thursday, December 31, 2009 1:24:25 AM(UTC)
Asad

Rank: Newbie

Groups: Registered, Registered Users
Joined: 2/28/2007(UTC)
Posts: 1

Dear Damien: As per your query following codings would appropriate. pr:=Input("Reversal amount", 0.001,100000,1); pk:=PeakBars(1,H ,pr)=0; tr:=TroughBars(1,L,pr)=0; oHi:=Zig(H ,pr,%); oLo:=Zig(L,pr,%); avg:=(oHi+oLo)/2; x:=If(H>Ref(H,-1) AND L<ref(L,-1) ,HIGH, If(H<=Ref(H,-1) AND L>Ref(L,-1),LOW, If(H<=Ref(H,-1) AND L<ref(L,-1) ,olo, If((Ref(LOW,-1)>(H>Ref(H,-1) AND L>Ref(L,-1))) ,HIGH , If((Ref(HIGH,-1)>(H>Ref(H,-1) AND L>Ref(L,-1))),LOW, If(avg>Ref(avg ,-1),L,H)))) )); X1:=Zig(x,pr,%); X1; But not equals to the indicator ploted on HSI graph that you had sent me via e-mail. You have to rewrite the rules if you want an accurate indicator equals to the indicator ploted on HSI graph . 1- Swing lines connect either Highs or Lows of individual bars - never Open or Close. 2 -If the next bar has a higher high and a higher low (or the same low) when compared to the previous bar, then the swing line goes up connecting the high of the next bar. 3- If the next bar has a lower high (or same high) and a lower low when compared to the previous bar, then the swing line goes down connecting the low of the next bar. 4- If the next bar is an inside bar (lower high and higher low than the previous bar), ignore it and don’t plot a line on it at all – wait for the next bar. 5- If the next br is an outside bar (higher high and lower low), plot a swing line on the high of an outside bar if the following bar (one after the outside bar) has a lower low than the outside bar, OR plot a swing line on the low of an outside bar if the following bar (one after the outside bar) has a higher high than the outside bar. However i tried to make it equal with the ploted indicator on HSI graph but some thing is missing or over the rules due these reasons i cant able to shape final. pr:=Input("Reversal amount", 0.001,100000,.96); pk:=PeakBars(1,H ,pr)=0; tr:=TroughBars(1,L,pr)=0; oHi:=Zig(H ,pr,%); oLo:=Zig(L,pr,%); avg:=(oHi+oLo)/2; x:=If(pk,ohi,If(tr,olo, If(Inside(),PREVIOUS, If(Outside(),LOW ,If(Outside()>Ref(H,-1),LOW,If(L>Ref(Outside(),-1),HIGH, avg)))))); X1:=Zig(x,pr,%); X1; Regards Asad Tirmazie Head of Equity Azee Securities (Pvt) Limited drfund21@yahoo.com 0092321-8247969
m_jor75  
#16 Posted : Monday, February 7, 2011 2:43:27 PM(UTC)
m_jor75

Rank: Member

Groups: Registered, Registered Users
Joined: 3/14/2010(UTC)
Posts: 11

Thanks: 1 times

Dear Asad,

I was searching the net if I can find a formula for a swing chart to plot over a candlestick or a bar chart that will ignore or the noise inbetween bars and give a clear market direction. I came up with a website but they do charge for using the swing chart but its not on metastock. Now Metastock version 11 has the Zigzag indicator but it there are many zigzags up and down which is not helpful.

I will use the swing chart for clear market or stock direction, and to identify a failure swing. I have seen the formula you have here and I did try it but its not much different that the Zigzag indicator.

I will plot a chart with a swing lines on it to show what I'm looking for if you can help in buliding the formula.

http://img89.imageshack.us/i/swing.gif/

Thank you

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.