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

Notification

Icon
Error

Options
Go to last post Go to first unread
Topkat  
#1 Posted : Saturday, March 11, 2006 1:25:21 AM(UTC)
Topkat

Rank: Advanced Member

Groups: Registered, Registered Users, Subscribers
Joined: 11/10/2004(UTC)
Posts: 31

Hello, I am having a problem with a function. As an example, if you pull up a chart for TXN and drop the standard MACD() indicator into a separate inner window. Create a new indicator using the code below and drop it onto the MACD() using the default 5 period look back (merge with scale on left). a:=MACD(); peri:=Input("Period",2,100,5); hic:= a>Ref(HHV(a,peri),-1) AND a>=Ref(HHV(a,peri),peri); y1t:=LastValue(ValueWhen( 2, hic=1, a )); y2t:=LastValue(ValueWhen( 1, hic=1, a )); x1t:=LastValue(ValueWhen( 2, hic=1 , Cum(1) )); x2t:=LastValue(ValueWhen( 1, hic=1 , Cum(1) )); {at:=(y1t-y2t)/(x1t-x2t);bt:=y1t-at*x1t;} yt:=(y1t-y2t)/(x1t-x2t)*Cum(1)+y1t-(y1t-y2t)/(x1t-x2t)*x1t; {yt:=at*cum(1)+bt;} e1:=a-yt; ret1:=LastValue(Cum(1)-(x1t+Int((x2t-x1t)/2)-1)); seg1:=LastValue(Int((x2t-x1t)/2+Int(2*peri/5)){+peri-1}); x1:=LastValue(Cum(1)-HHVBars(Ref(e1,-ret1),seg1)-ret1); y1:=LastValue(ValueWhen(1,x1=Cum(1),a)); ret2:=LastValue(Cum(1)-(x2t+Int(4*peri/5))); seg2:=LastValue(Int((x2t-x1t)/2)+Int(4*peri/5)); x2:=LastValue(Cum(1)-HHVBars(Ref(e1,-ret2),seg2)-ret2); y2:=LastValue(ValueWhen(1,x2=Cum(1),a)); {a:=(y1-y2)/(x1-x2);b:=y1-a*x1;} a:=(y1-y2)/(x1-x2); HiTL:=If(Cum(1)>x1t-5,(y1-y2)/(x1-x2)*Cum(1)+y1-(y1-y2)/(x1-x2) *x1,BarsSince(Cum(1)>x1t-5)); Diff:=Ref(HiTL-a,-LastValue(Cum(1)-x2)); decal:=LastValue(HHV(Diff,x2-x1)); HiTL If I create another indicator using the above code, but change the last line from 'HiTL' to 'Cross(A,HiTL)', drop it into a new inner window for TXN... I get a '1' for a cross of the MACD() up through HiTL on 2/10/06. Viewing the MACD() indicator, the cross appears to have actially taken place on 3/1/06. Thank you for any help you can provide.
hayseed  
#2 Posted : Saturday, March 11, 2006 3:16:44 AM(UTC)
hayseed

Rank: Advanced Member

Groups: Registered, Registered Users, Subscribers
Joined: 3/7/2005(UTC)
Posts: 1,346

hey topcat..... kinda looks like your code is ploting peak to peak trend line of the macd crosses..... the 1 is marking the hitl crossing the 0 line, with the default setting at 5.... change the setting to 12 on both indicators and the 1 marker and trend line move to the next peak and 0 line cross.... is there a reason you are not combining the 2 into 1.... such as last line of ;
HiTL; Cross(a,hitl)
plots the trend line and also the cross markers..... very interesting code .... still fiddling with it.... are you wanting it to signal a macd cross or something.....h
Topkat  
#3 Posted : Saturday, March 11, 2006 4:16:25 AM(UTC)
Topkat

Rank: Advanced Member

Groups: Registered, Registered Users, Subscribers
Joined: 11/10/2004(UTC)
Posts: 31

Hi hayseed... Yes, it plots a line from peak to peak (depending on the lookback period specified). I am not combining the 2 into 1 because I use the last line as "HiTL" for an indicator in the indicator list to drop on the MACD() for a visual look. A last line of Cross(A,HiTL)... I would like to run an exploration to find where the MACD() has crossed above a trend line connecting previous peaks. The different columns in the exploration will contain different periods (i.e. ColA 5 periods; ColB 10 periods... and so on). I want to find a Cross(A,HiTL) for any of the periods specified, if it occurred (hope that makes sense). Thank you for pointing out it is flagging my HiTL crossing the 0 line with the command Cross(a,HiTL). I could not figure out what it was flagging. I would like to flag where the MACD() crosses up through the HiTL (breaks the trendline). No sure why it flags the HiTL crossing 0... I'll look at it some more tomorrow.
hayseed  
#4 Posted : Saturday, March 11, 2006 4:43:03 AM(UTC)
hayseed

Rank: Advanced Member

Groups: Registered, Registered Users, Subscribers
Joined: 3/7/2005(UTC)
Posts: 1,346

hey topcat.... use Cross(MACD(),HiTL) as last line for the macd breaking the trend line..... h
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.