PureBytes Links
Trading Reference Links
|
DT:
Many many thanks. This (with modifications-see below) was just want I
wanted and needed.
I prefer the hand drawn (dragged) regression channel but will experiment
with the auto support line you have provided.
Ken
As modified for Regression channel (RU = upper line, RL = lower line)
x=Cum(1);
SU=Study("RL");
X1=ValueWhen(Cum(IsTrue(SU))==1,X);
Y1=ValueWhen(X==X1,SU);
X2=LastValue(X);
Y2=LastValue(SU);
SLOPE=(Y2-Y1)/(X2-X1);
YP=LastValue(Highest(IsTrue(SU)*H));
XP=LastValue(ValueWhen(H==YP,X));
RE=Study("RU");
ratio=(C-SU)/(RE-SU);
Title=Name()+", Ratio="+WriteVal(RATIO);
GraphXSpace=5;
Plot(ratio,"",6,1);
Plot(1,"",9,1);
Plot(0,"",9,1);
-----Original Message-----
From: DIMITRIS TSOKAKIS [mailto:TSOKAKIS@xxxxxxxxx]
Sent: Thursday, September 23, 2004 8:35 AM
To: amibroker@xxxxxxxxxxxxxxx
Subject: [amibroker] Re: Oscillator Within Linear Reg Lines (DT?)
Ken,
There are numerous variations already posted here, but a fresh one is
always better...
In the following code SU is the [automatic] support for per=5, RE is
the parallel to SU from the highest H [as long as SU exists].
The Ratio will be equal to 0 when C=SU, negative when C<SU, from 0 to
1 as soon as RE>C>SU and greater than 1 when C>RE.
I think it is a representative scaling.
per = 5;//calibrate the sensitivity
x = Cum(1);
s1=L;s11=H;
pS = TroughBars( s1, per, 1 ) == 0;
endt= LastValue(ValueWhen( pS, x, 1 ));
startt=LastValue(ValueWhen( pS, x, 2 ));
dtS =endt-startt;
endS = LastValue(ValueWhen( pS, s1, 1 ) );
startS = LastValue( ValueWhen( pS, s1, 2 ));
aS = (endS-startS)/dtS;bS = endS;
trendlineS = aS * ( x -endt ) + bS;
SU = IIf(x>startt-1,trendlineS,-1e10);
Plot(SU,"\nSU",colorYellow,styleThick);
X1=ValueWhen(Cum(IsTrue(SU))==1,X);
Y1=ValueWhen(X==X1,SU);
X2=LastValue(X);Y2=LastValue(SU);
SLOPE=(Y2-Y1)/(X2-X1);
YP=LastValue(Highest(IsTrue(SU)*H));
XP=LastValue(ValueWhen(H==YP,X));
RE=YP+SLOPE*(X-XP);
Plot((SU/SU)*RE,"\nRE",colorYellow,styleThick);
Plot(C,"\nC",1,64);
GraphXSpace=2;
ratio=(C-SU)/(RE-SU);
Title=Name()+", Ratio="+WriteVal(RATIO);
Note also that SU may be replaced by another line of your preference,
code or manually drawn.
Dimitris
--- In amibroker@xxxxxxxxxxxxxxx, "Ken Close" <closeks@xxxx> wrote:
> DT (or others):
>
> Can you (or anyone) point me to any previous messages or any
previous
> work which has been done which would accomplish the following. It
seems
> like you would know given all of your mathematical creations
(oblique
> fib lines, parabolic trendlines, etc).
>
> I would like to manually draw a regression channel from date A to
date
> B.
> I would then like a plot to show the position, in percent, of the
price
> between the two outer regression lines. Alternatively, this code
would
> also work within any two manually drawn and named trend lines that
are
> roughly parallel as long as they start and stop on the same bar.
>
> Ideally, the code would show greater than 100% (when price goes
outside
> the upper regression line) or less than zero % (when price goes
below
> the lower bar). It seems it should link to regression lines that
> automatically extend.
>
> Can you or anyone point to a message or to any code that could
> accomplish this?
>
> Many thanks for any help.
>
> Ken
>
> ---
> Outgoing mail is certified Virus Free.
> Checked by AVG anti-virus system (http://www.grisoft.com).
> Version: 6.0.754 / Virus Database: 504 - Release Date: 9/6/2004
Check AmiBroker web page at:
http://www.amibroker.com/
Check group FAQ at:
http://groups.yahoo.com/group/amibroker/files/groupfaq.html
Yahoo! Groups Sponsor
ADVERTISEMENT
Yahoo! Groups Links
• To visit your group on the web, go to:
http://groups.yahoo.com/group/amibroker/
• To unsubscribe from this group, send an email to:
amibroker-unsubscribe@xxxxxxxxxxxxxxx
• Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.
---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.768 / Virus Database: 515 - Release Date: 9/22/2004
------------------------ Yahoo! Groups Sponsor --------------------~-->
$9.95 domain names from Yahoo!. Register anything.
http://us.click.yahoo.com/J8kdrA/y20IAA/yQLSAA/GHeqlB/TM
--------------------------------------------------------------------~->
Check AmiBroker web page at:
http://www.amibroker.com/
Check group FAQ at: http://groups.yahoo.com/group/amibroker/files/groupfaq.html
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/amibroker/
<*> To unsubscribe from this group, send an email to:
amibroker-unsubscribe@xxxxxxxxxxxxxxx
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/
|