x = Cum(1);
per = Param("Percent",3,1,5,1);
s1=L;
s11=H;
pS = TroughBars( s1, per, 1 ) == 0;
endt= LastValue(ValueWhen( pS, x, 1 ));
startt=LastValue(ValueWhen( pS, x, 2 ));
endS = LastValue(ValueWhen( pS, s1, 1 ) );
startS = LastValue( ValueWhen( pS, s1, 2 ));
dtS =endt-startt;
aS = (endS-startS)/dtS;
bS = endS;
trendlineS = aS * ( x -endt ) + bS;
pR = PeakBars( s11, per, 1 ) == 0;
endt1= LastValue(ValueWhen( pR, x, 1 ));
startt1=LastValue(ValueWhen( pR, x, 2 ));
endR = LastValue(ValueWhen( pR, s11, 1 ) );
startR = LastValue( ValueWhen( pR, s11, 2 ));
DTR=ENDT1-STARTT1;
aR = (endR-startR)/dtR;
bR = endR;
trendlineR = aR * ( x -endt1 ) + bR;
BEGIN=Min(STARTT,STARTT1);
TRS = IIf(x>BEGIN-10,trendlineS,-1e10);
TRR = IIf(x>BEGIN-10,trendlineR,-1e10);
Condcolor=(Cross(C,trendlineR) AND X>ENDT1) OR (Cross(trendlineS,C) AND
X>ENDT);
BarColor=IIf(Condcolor,7,1);
Plot(C,"Close",BarColor,styleCandle);
Plot(TRS,"Support",colorYellow,styleLine);
Plot(TRR,"Resist",colorYellow,styleLine);
fill=Param("style",2,1,2,1);
style=IIf(fill==1,styleHistogram,IIf(fill==2,styleArea,Null));
x=IIf(trs > trr,trr,trs);
Plot(x,"",colorWhite,style);
Plot(trr,"",colorDarkGrey,style);
_SECTION_END();
No comments:
Post a Comment
Thanks