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)
|
Define the events (in both time (x-axis) and price (y-axis)) and use a lerp function to join (and extend)
Code:
A:=BBandTop(C,20,S,2);
B:=BBandBot(C,20,S,2);
price1:=A;
time1:=Ref(A,-1) > Max(A,Ref(A,-2));
price2:=B;
time2:=Ref(B,-1) < Min(B,Ref(B,-2));
{Jose's code from here}
{restrict to last events}
time1:=time1 AND Cum(time1)=LastValue(Cum(time1));
time2:=time2 AND Cum(time2)=LastValue(Cum(time2));
{sort events}
t1pds:=LastValue(BarsSince(time1));
t2pds:=LastValue(BarsSince(time2));
x1:=If(t1pds>=t2pds,time1,time2);
x2:=If(t1pds>=t2pds,time2,time1);
y1:=If(t1pds>=t2pds,price1,price2);
y2:=If(t1pds>=t2pds,price2,price1);
{fix coordinates}
y1:=ValueWhen(1,x1,y1);
y2:=LastValue(ValueWhen(1,x2,y2));
b1:=LastValue(BarsSince(x1));
b2:=LastValue(BarsSince(x2));
line:=y1+BarsSince(x1)*(y2-y1)/(b1-b2);
{plot}
line;
Edited by user Thursday, April 20, 2017 11:47:03 AM(UTC)
| Reason: Fixed code tags
|
1 user thanked wabbit for this useful post.
|
|