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

Notification

Icon
Error

Options
Go to last post Go to first unread
RUAGOODP  
#1 Posted : Saturday, June 25, 2005 7:05:59 AM(UTC)
RUAGOODP

Rank: Advanced Member

Groups: Registered, Registered Users, Unverified Users
Joined: 1/13/2005(UTC)
Posts: 87
Location: perth australia

Hi I am looking to coding a swing line such that it ignores the opening and closing price(except on an outside day)and merely looks at the total range for the day. The swing goes to the extreme of price each day. This is what I have found so far (I think it was posted by victor_h maybe related to our henry) H1:= HIGH; H2:= Ref(H1,-1); L1:= LOW; L2:= Ref(L1,-1); A1:= H1 > H2 AND L1 >= L2; {Rally} B1:= H1 <= H2 AND L1 < L2; {Reaction} C1:= H1 > H2 AND L1 < L2; {Outside} D1:= A1+B1+C1=0; {Inside} E1:=If(D1 OR Inside(),PREV, If(C1 AND PREV>Ref(MP(),-1),HIGH, If(C1 AND PREV<Ref(MP(),-1),LOW, If(B1,L,If(A1,H,PREV))))); F1:=If(MP()<E1, HighestSince(1,MP()>E1,H), LowestSince(1,MP()<E1,L)); SW:= Zig(F1,0.0001,%); SW; However if you look at the chart of BSL(Bluescope Steel ASX)on the 9th Feb 2004 it fails to allocate the high on that day as a swing high because the next day(10th Feb 2004) had a higher high. But this next day (10th Feb 2004) also had a lower low than the 9th Feb 2004. So I want this swing line to acknowledge the swing high on the 9th Feb 2004 and then to acknowledge the swing low on the 10th Feb 2004 even though the high on the 10th Feb 2004 had a higher high than the high on the 9th Feb 2004.Does that make sense? Hope someone can help Cheers Norman
wabbit  
#2 Posted : Saturday, June 25, 2005 7:18:25 AM(UTC)
wabbit

Rank: Advanced Member

Groups: Registered, Registered Users, Subscribers, Unverified Users
Joined: 10/28/2004(UTC)
Posts: 3,111
Location: Perth, Western Australia

Was thanked: 16 time(s) in 16 post(s)
RUAGOODP wrote:
E1:=If(D1 OR Inside(),PREV, If(C1 AND PREV>Ref(MP(),-1),HIGH, If(C1 AND PREV<Ref(MP(),-1),LOW, If(B1,L,If(A1,H,PREV)))));
Without spending too much time right now - but just to give you something to think about whilst I go back out into the garden..... SWMBO is getting shirty! In your code above you explicitly describe what to do in the following cases: C1 AND PREV>Ref(MP(),-1) and C1 AND PREV<Ref(MP(),-1) What about C1 AND PREV=Ref(MP(),-1)? This alone might cause errors. You should try to account for every possibility, and when you want to get really pedantic, there are combinations that might need due consideration: < > = <= >= Hope this helps, in the mean time. wabbit :D
wabbit  
#3 Posted : Saturday, June 25, 2005 7:38:11 AM(UTC)
wabbit

Rank: Advanced Member

Groups: Registered, Registered Users, Subscribers, Unverified Users
Joined: 10/28/2004(UTC)
Posts: 3,111
Location: Perth, Western Australia

Was thanked: 16 time(s) in 16 post(s)
... and in the same context... You have coded the rally, reaction, inside and outside days, but what about those occassions of which you have already queried? What about those days that arent one of those days coded? Test for them using code like, to find uncategorised days: dRally OR dReaction OR dOutside OR dInside Now in your case, every day fits into one of these four categories.... but you might consider that you need to create another category to deal with the days of you problem. wabbit :D P.S. I have modified your code and variables a bit to ease my readability. Perhaps you might find these variable names a little easier to use. When the code works well, you can replace the long variable names with short one to save space - but only do that when the code is working perfectly! H1:=Ref(H,-1); L1:=Ref(L,-1); dRally:=H>H1 AND L>=L1; dReaction:=H<=H1 AND L<L1; dOutside:=H>H1 AND L<L1; dInside:=dRally+dReaction+dOutside=0; {consider adding more categories in here} E0:=If(dInside OR Inside(),PREV, If(dOutside AND PREV>Ref(MP(),-1),H, If(dOutside AND PREV<Ref(MP(),-1),L, If(dReaction,L,If(dRally,H,PREV))))); F0:=If(MP()<E0, HighestSince(1,MP()>E0,H), LowestSince(1,MP()<E0,L)); SW:=Zig(F0,0.0001,%); SW;
RUAGOODP  
#4 Posted : Saturday, June 25, 2005 8:30:01 AM(UTC)
RUAGOODP

Rank: Advanced Member

Groups: Registered, Registered Users, Unverified Users
Joined: 1/13/2005(UTC)
Posts: 87
Location: perth australia

Thanks wabbit. It got me thinking which I don't do too often. I copied this code from somewhere but your input actually got me looking at the code rather than just taking it for face value. I think I have worked it out. Still fine tuning it :P Cheers Norman
wabbit  
#5 Posted : Saturday, June 25, 2005 10:16:33 AM(UTC)
wabbit

Rank: Advanced Member

Groups: Registered, Registered Users, Subscribers, Unverified Users
Joined: 10/28/2004(UTC)
Posts: 3,111
Location: Perth, Western Australia

Was thanked: 16 time(s) in 16 post(s)
Good luck with it.... let us know how you go. Perhaps you would like to enlighten all of us how you overcame the problem (in the successful-predicative-future sense)! There is always a danger of people "just" copying code without trying to understand how it works. This situation has been mentioned often in this forum (and others). It IS important to understand someone else's code, because its your money that is going after it! wabbit :D
RUAGOODP  
#6 Posted : Sunday, June 26, 2005 6:22:22 AM(UTC)
RUAGOODP

Rank: Advanced Member

Groups: Registered, Registered Users, Unverified Users
Joined: 1/13/2005(UTC)
Posts: 87
Location: perth australia

Hi Wabbit, At this stage I am here with the formula having solved my initial problem H1:= HIGH; H2:= Ref(H1,-1); L1:= LOW; L2:= Ref(L1,-1); A1:= H1 > H2 AND L1 >= L2; {Rally} B1:= H1 <= H2 AND L1 < L2; {Reaction} C1:= H1 > H2 AND L1 < L2; {Outside} D1:= A1+B1+C1=0; {Inside} G1:= L1>H2; E1:= If(D1 OR Inside(),L, If(C1,LOW, If(B1,L, If(G1,H, If(A1,H,PREV))))); F1:=If(MP()<E1, HighestSince(1,MP()>E1,H), LowestSince(1,MP()<E1,L)); SW:= Zig(F1,0.0001,%); SW; Still fine tuning Cheers Norman
Users browsing this topic
Guest (Hidden)
Similar Topics
How to draw a swing line using MDK. (MetaStock Developer's Kit (MDK) Assistance)
by penguin 8/20/2012 12:57:49 AM(UTC)
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.