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

Notification

Icon
Error

Options
Go to last post Go to first unread
homano  
#1 Posted : Saturday, March 25, 2017 5:38:20 AM(UTC)
homano

Rank: Member

Groups: Registered Users, Subscribers
Joined: 8/19/2014(UTC)
Posts: 23

Thanks: 4 times

Hello, 

Please, I want to make a Trend Line between two Points, Point1 :  A:=BBandTop(C,20,S,2); ref(A,-1) > ref(A,-2) and A < ref(A,-1); Point2 :  B:= BBandBot(C,20,S,2); ref(B,-1) < ref(B,-2) and B > ref(B,-1)

Edited by user Saturday, March 25, 2017 5:50:32 AM(UTC)  | Reason: Not specified

wabbit  
#2 Posted : Sunday, March 26, 2017 6:06:02 AM(UTC)
wabbit

Rank: Advanced Member

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

Was thanked: 12 time(s) in 12 post(s)
Are these the only two points on the chart, between which you want to draw the trendline? Or, do you need to connect all of the points as defined by your events?
homano  
#3 Posted : Sunday, March 26, 2017 1:48:02 PM(UTC)
homano

Rank: Member

Groups: Registered Users, Subscribers
Joined: 8/19/2014(UTC)
Posts: 23

Thanks: 4 times
Yes, only  two points , Thank you.
wabbit  
#4 Posted : Monday, March 27, 2017 1:05:02 AM(UTC)
wabbit

Rank: Advanced Member

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

Was thanked: 12 time(s) in 12 post(s)
Well, you could modify the code Roy (MSTT) posted for you six months ago, which does a very similar job; or modify the two-points trendline Jose has on his site.
homano  
#5 Posted : Monday, March 27, 2017 9:56:16 AM(UTC)
homano

Rank: Member

Groups: Registered Users, Subscribers
Joined: 8/19/2014(UTC)
Posts: 23

Thanks: 4 times
In fact I thank Roy very much and I started Writing my own codes from the code he gave me. The code from Roy connects two points in the same Indicator. Now I want to connect two points from two different indicators. I spent a lot of time trying without a result. Also I tried to Understand Jose code before you Post a reply , actually the Code is complex , I do not want all the code, I want the instruction (code) that Connect between two points Like this from  Roy Code. Line:=ValueWhen(1,Peak1,R)+ Cum(Ref(Cum(PkRs1),-1)<>0)*Change; Thank you,
wabbit  
#6 Posted : Monday, March 27, 2017 2:07:17 PM(UTC)
wabbit

Rank: Advanced Member

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

Was thanked: 12 time(s) in 12 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

thanks 1 user thanked wabbit for this useful post.
homano on 3/27/2017(UTC)
Users browsing this topic
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.