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

Notification

Icon
Error

Options
Go to last post Go to first unread
Derek Worswick  
#1 Posted : Monday, July 27, 2015 4:55:12 PM(UTC)
Derek Worswick

Rank: Advanced Member

Groups: Registered, Registered Users, Subscribers, Unverified Users
Joined: 8/11/2005(UTC)
Posts: 104

Hello, I have tried to modify this indicator to plot a Support line from two lows (troughs) and plot a parallel channel line to a high peak But I have got the Vertical Displacement ( Shift ) (decal ) incorrect Could you please correct the code Thank you in advance Kind regards Derek ................................... *code* { Trend Resistance Line / Channel LLV } pds:=Input("Lookback Periods",2,100,50); hic:= L<Ref(LLV(L,pds),-1) AND L<=Ref(LLV(L,pds),pds); y1t:=LastValue(ValueWhen( 2, hic=1, L )); y2t:=LastValue(ValueWhen( 1, hic=1, L )); 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:=L-yt; ret1:=LastValue(Cum(1)-(x1t+Int((x2t-x1t)/2)-1)); seg1:=LastValue(Int((x2t-x1t)/2+Int(2*pds/5)){+pds-1}); x1:=LastValue(Cum(1)-LLVBars(Ref(e1,-ret1),seg1)-ret1); y1:=LastValue(ValueWhen(1,x1=Cum(1),L)); ret2:=LastValue(Cum(1)-(x2t+Int(4*pds/5))); seg2:=LastValue(Int((x2t-x1t)/2)+Int(4*pds/5)); x2:=LastValue(Cum(1)-LLVBars(Ref(e1,-ret2),seg2)-ret2); y2:=LastValue(ValueWhen(1,x2=Cum(1),L)); {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-L,-LastValue(Cum(1)-x2t)); decal:=LastValue(LLV(Diff,x2t-x1t)); HiTL; HiTL-decal */code* ===================================================== The original Indicator plots a resistance line from Two highs (peaks) and plots a channel from a low (trough) point I have not posted the original code to avoid confusion between the two codes

Edited by user Saturday, August 1, 2015 9:09:00 PM(UTC)  | Reason: Wrong Link

Derek Worswick  
#2 Posted : Monday, July 27, 2015 6:41:30 PM(UTC)
Derek Worswick

Rank: Advanced Member

Groups: Registered, Registered Users, Subscribers, Unverified Users
Joined: 8/11/2005(UTC)
Posts: 104

Hello, The Link to the original formula code should be: http://trader-online.tk/...stance_Line-Channel.html sorry about error Derek
Derek Worswick  
#3 Posted : Friday, July 31, 2015 8:03:05 AM(UTC)
Derek Worswick

Rank: Advanced Member

Groups: Registered, Registered Users, Subscribers, Unverified Users
Joined: 8/11/2005(UTC)
Posts: 104

HI, The correct code below was written by "FREDCOM" with many thanks to FREDCOM Link: http://www.wisestocktrader.com/...sties/266-otomatik-trend *code* peri:=Input("Période?",2,100,14); {by FREDCOM, 26May2003 --> V1.13} loc:= L<Ref(LLV(L,peri),-1) AND L<=Ref(LLV(L,peri),peri); y1t:=LastValue(ValueWhen( 2, loc=1, L )); y2t:=LastValue(ValueWhen( 1, loc=1, L )); x1t:=LastValue(ValueWhen( 2, loc=1, Cum(1) )); x2t:=LastValue(ValueWhen( 1, loc=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:=L-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)-LLVBars(Ref(e1,-ret1),seg1)-ret1); y1:=LastValue(ValueWhen(1,x1=Cum(1),L)); ret2:=LastValue(Cum(1)-(x2t+Int(5*peri/5))); seg2:=LastValue(Int((x2t-x1t)/2)+Int(4*peri/5)); x2:=LastValue(Cum(1)-LLVBars(Ref(e1,-ret2),seg2)-ret2); y2:=LastValue(ValueWhen(1,x2=Cum(1),L)); {a:=(y1-y2)/(x1-x2);b:=y1-a*x1;} a:=(y1-y2)/(x1-x2); LoTL:=If(Cum(1)>x1t-5,(y1-y2)/(x1-x2)*Cum(1)+y1-(y1-y2)/(x1-x2) *x1,BarsSince(Cum(1)>x1t-5)); Diff:=Ref(H-LoTL,-LastValue(Cum(1)-x2t)); decal:=LastValue(HHV(Diff,x2t-x1t)); LoTL;LoTL+decal; */code* Derek

Edited by user Saturday, August 1, 2015 9:19:28 PM(UTC)  | Reason: removed blank lines

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.