[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [amibroker] PEAK AND TROUGH TRENDLINE



PureBytes Links

Trading Reference Links

Here is the code that I am Using. Does this Help.

Thank you
Anthony

Tomasz Janeczko wrote:

> Hi,
>
> Click on the trend line with right mouse button, choose "Properties" and
> switch off "Right extend" box in the properties window.
>
> Best regards,
> Tomasz Janeczko
> amibroker.com
>
> ----- Original Message -----
> From: "Anthony Faragasso" <ajf1111@xxxx>
> To: <amibroker@xxxxxxxxxxxxxxx>
> Sent: 01 October, 2001 19:13
> Subject: [amibroker] PEAK AND TROUGH TRENDLINE
>
> tomasz;
>
> please look at the attached image, is it possible to have the trendline
> stop at the two points, and not extend through.
>
> Please help,
> thank you,
> anthony
>
>
>
> Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
>
> --------------------------------------------------------------------------------
>
>
>
>
> Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/

/*TRENDLINE*/
MaxGraph=8;
Graph0 = C;
Graph0Style=128;
Graph0BarColor=1;
x = Cum(1);
per = 3;
s1=L;
s11=H;
RANKt=3;
RANKp=4;
pS = TroughBars( s1, per, 1 ) == 0;
endt= LastValue(ValueWhen( pS, x, RANKt ));/*trough time*/
pR = PeakBars( s11, per, 1 ) == 0; 
endt1= LastValue(ValueWhen( pR, x, RANKp ));/*peak time*/
dt=IIf(endt-endt1>0,endt-endt1,endt1-endt); 
endS = LastValue(ValueWhen( pS, s1, RANKt ) );/*trough value*/
endR = LastValue(ValueWhen( pR, s11, RANKp ) );/*peak value*/
aS=IIf(endt-endt1>0,(endS-endR)/dt,-(endS-endR)/dt);/*slope*/
bS=IIf(endt-endt1>0,endS,endR);/*beta*/
TR=aS*(x-Max(endt,endt1))+bS;/*TRENDLINE EQUATION*/

Graph1 = IIf(x>Min(endt,endt1)-1,tr,-1e10);

/*graph3=Zig(s11,per);*/
/*graph3barcolor=9;*/
/*graph4=Zig(s1,per);*/
/*graph4barcolor=0;*/

/* ========================*/

/* My Addition*/
/* Butterfly Pattern*/
/* Second leg of Butterfly (B)*/

a1=endS;
a2=endR;
a3=endS-endR;
a4=endR-endS;
a5=a2+.786*(a3);
a6=a1+.786*(a4);

x1=IIf(RANKt > RANKp,a1,a2);
a=IIf(RANKt > RANKp,a2,a1);
b=IIf(RANKt > RANKp,a5,a6);
startv=a;
endv=b;
startb=a;
endb=b;
as=(startv-endv)/(startb-endb);
bs=endv;
tr=as*(b-endb)+bs;
Graph2=tr;
Graph2Style=128+8;
Graph2Color=6;


Title=Name()+" Peak value = "+WriteVal(endR,format=1.2)+" Trough value = "+WriteVal(endS,format=1.2)+" / "+" ( B ) Retracement = "+WriteVal(b,format=1.2)+" Trendline at " +WriteVal(tr,format=1.2);