- Katılım
- 23 Eki 2020
- Mesajlar
- 1,826
From: rsb_44 <rsb_44@hotmail.com> To: equismetastock@yahoogroups.com <equismetastock@yahoogroups.com> Date: Wednesday, June 1, 2005, 5:16:17 PM Subject: [EquisMetaStock Group] Diagonal line drawn by indicator I am able to find two points with valuewhen. Is there a way to have a diagonal line drawn between those two points via code? How about one point and its slope (rate of change)? (y=mx+b) TIA Ron =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= From: pumrysh <no_reply@yahoogroups.com> To: equismetastock@yahoogroups.com <equismetastock@yahoogroups.com> Date: Wednesday, June 1, 2005, 7:33:53 PM Subject: [EquisMetaStock Group] Re: Diagonal line drawn by indicator Ron, Try this: |
|
BarBack Z {Will draw a line from one High to the next---back in time} {Reference highs are also displayed within the window} len:=Input("Periods for Ref High(Set > Barsback)",8,100,20); Signal:=Ref(H,-len); Barbk:=Input("Barsback High",1,100,8); Signal2:=Ref(H,-Barbk); LastBar:=Cum(1)=LastValue(Cum(1)-(len)); bacdis1:=ValueWhen(1,LastBar,LastValue(Signal)); 1stRefPnt:=Ref(Ref(bacdis1,-Barbk),Barbk); {end} bacdis2:=ValueWhen(1,LastBar,LastValue(Signal2)); 2ndRefPnt:=Ref(Ref(bacdis2,-Barbk),Barbk); {end} {Line Plot } D1:=LastValue(Cum(1))-LastValue(LEN); {D1 is first high of line} D2:=LastValue(Cum(1))-LastValue(BARBK); {D2 is last high of line} P1:=1stRefPnt; {start-of-line data array} P2:=2ndRefPnt; {end-of-line data array} V1:=ValueWhen(1,D1,P1); V2:=ValueWhen(1,D2,P2); B1:=LastValue(Cum(1))-D1; B2:=LastValue(Cum(1))-D2; LINE:=V1-(BarsSince(Cum(1)=D1)*( (V1-V2)/(B1-B2))); LINE; 1stRefPnt; 2ndRefPnt; |
From: Ron Berlin <rsb_44@hotmail.com>
To: equismetastock@yahoogroups.com <equismetastock@yahoogroups.com>
Date: Wednesday, June 1, 2005, 10:12:12 PM
Subject: [EquisMetaStock Group] Re: Diagonal line drawn by indicator
Pumrysh-
Thanks. I can adjust it to get what I want.
Ron
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
From: mgf_za_1999 <no_reply@yahoogroups.com>
To: equismetastock@yahoogroups.com <equismetastock@yahoogroups.com>
Date: Wednesday, June 1, 2005, 5:35:57 PM
Subject: [EquisMetaStock Group] Re: Diagonal line drawn by indicator
Hi there,
Suppose you can find the two points' coordinates as X1,Y1 and X2,Y2.
The X1 and X2 will typically be from something like 'Cum(1)' combined with your 'valuewhen' function, something like
X1 = Lastvalue( Sum( Cum(1) * valuewhen(...) ) );
Y1 = Lastvalue( Sum( C * valuewhen(...) ) );
etc.
Now, to get the line, it would look something like
xx = Cum(1);
mm = (Y2-Y1)/(X2-X1);
bb = Y1-mm*X1;
{Final plot}
(xx>=X1)*(xx<=X2)*(mm*xx+bb);
This is not tested, but you should get the idea.... It will draw a line between the points and zero otherwise. To start at Y1 and end at Y2, do something like
(xx>=X1)*(xx<=X2)*(mm*xx+bb)+(xx<X1)*Y1+(xx>X2)*Y2;
with the final line.
Regards
MG Ferreira
TsaTsa EOD Programmer and trading model builder
http://www.ferra4models.com
http://fun.ferra4models.com
Source / From:To: equismetastock@yahoogroups.com <equismetastock@yahoogroups.com>
Date: Wednesday, June 1, 2005, 10:12:12 PM
Subject: [EquisMetaStock Group] Re: Diagonal line drawn by indicator
Pumrysh-
Thanks. I can adjust it to get what I want.
Ron
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
From: mgf_za_1999 <no_reply@yahoogroups.com>
To: equismetastock@yahoogroups.com <equismetastock@yahoogroups.com>
Date: Wednesday, June 1, 2005, 5:35:57 PM
Subject: [EquisMetaStock Group] Re: Diagonal line drawn by indicator
Hi there,
Suppose you can find the two points' coordinates as X1,Y1 and X2,Y2.
The X1 and X2 will typically be from something like 'Cum(1)' combined with your 'valuewhen' function, something like
X1 = Lastvalue( Sum( Cum(1) * valuewhen(...) ) );
Y1 = Lastvalue( Sum( C * valuewhen(...) ) );
etc.
Now, to get the line, it would look something like
xx = Cum(1);
mm = (Y2-Y1)/(X2-X1);
bb = Y1-mm*X1;
{Final plot}
(xx>=X1)*(xx<=X2)*(mm*xx+bb);
This is not tested, but you should get the idea.... It will draw a line between the points and zero otherwise. To start at Y1 and end at Y2, do something like
(xx>=X1)*(xx<=X2)*(mm*xx+bb)+(xx<X1)*Y1+(xx>X2)*Y2;
with the final line.
Regards
MG Ferreira
TsaTsa EOD Programmer and trading model builder
http://www.ferra4models.com
http://fun.ferra4models.com
EquisMetastock[at]yahoogroups[dot]com