Plot( 100, /* defines the height of the ribbon in percent of pane width */"ribbon",
IIf( up1, colorGreen, IIf( sel1, colorRed,IIf(bluestar, colorDarkBlue, 0 ))), /* choose color */
styleOwnScale|styleArea|styleNoLabel, -0.5, 100 );
Plot( 100, /* defines the height of the ribbon in percent of pane width */"ribbon",
IIf( up1, colorGreen, IIf( sel1, colorRed,IIf(bluestar, colorDarkBlue, colorBlack ))), /* choose color */
styleOwnScale|styleArea|styleNoLabel, -0.5, 100 );
Plot( 100, /* defines the height of the ribbon in percent of pane width */"ribbon",
IIf( up1, colorBlack, IIf( sel1, colorBlack,IIf(bluestar, colorBlack, 0 ))), /* choose color */
styleOwnScale|styleArea|styleNoLabel, -0.5, 100 );
///////////////////////////////////////////////////////
Plot( 100, /* defines the height of the ribbon in percent of pane width */"ribbon",
IIf( up1, colorBlack, IIf( sel1, colorBlack,IIf(bluestar, colorBlack, 0 ))), /* choose color */
styleOwnScale|styleArea|styleNoLabel, -0.5, 100 );
///////////////////////////////////////////////////////
Plot( 100, /* defines the height of the ribbon in percent of pane width */"ribbon",
IIf( up1, colorBlack, IIf( sel1, colorBlack,IIf(bluestar, colorBlack, colorBlack ))), /* choose color */
styleOwnScale|styleArea|styleNoLabel, -0.5, 100 );
SetChartBkColor(colorBlack);
Buy = TimeNum()==91700;
Sell=0;
ApplyStop(1,1,1,1);
Short=TimeNum()==91700;
Cover=0;
ApplyStop(1,1,1,1);
_SECTION_BEGIN("RSI Trendlines and Wedges");
/*RSI Trendlines and Wedges*/
G=0;// set G=1, 2, 3, ... to see previous Resistance trendlines
GG=0;// set G=1, 2, 3, ... to see previous Support trendlines
x = Cum(1);
per = 1;// sensitivity calibration
s1=RSI();s11=RSI();
Plot(RSI(),"RSI",9,8);
pS = TroughBars( s1, per, 1 ) == 0;
endt= LastValue(ValueWhen( pS, x, 1+GG ));
startt=LastValue(ValueWhen( pS, x, 2+GG ));
dtS =endt-startt;
endS = LastValue(ValueWhen( pS, s1, 1+GG ) );
startS = LastValue( ValueWhen( pS, s1, 2+GG ));
aS = (endS-startS)/dtS;
bS = endS;
trendlineS = aS * ( x -endt ) + bS;// the Support trendline equation
Plot(IIf(x>startt-6 AND TRENDLINES>0 AND TRENDLINES<100,trendlineS,-1e10),"Support",IIf(as>0,5,4),8);
pR = PeakBars( s11, per, 1 ) == 0;
endt1= LastValue(ValueWhen( pR, x, 1+G ));
startt1=LastValue(ValueWhen( pR, x, 2+G ));
dtR =endt1-startt1;
endR = LastValue(ValueWhen( pR, s11, 1+G ) );
startR = LastValue( ValueWhen( pR, s11, 2 +G ));
aR = (endR-startR)/dtR;
bR = endR;
trendlineR = aR * ( x -endt1 ) + bR;// the Resistance trendline equation
Plot(IIf(x>startT1-6 AND TRENDLINER>0 AND TRENDLINER<100,trendlineR,-1e10),"Resistance",IIf(Ar>0,5,4),8);
Ascwedge=Ar>0.5 AND As>sqrt(2)*Ar AND trendlineR>trendlineS;
Descwedge= As<-0.5 AND As>Ar/sqrt(2) AND trendlineR>trendlineS;
Filter=1;
AddColumn(Ascwedge,"AscWedge",1.0);
AddColumn(DescWedge,"DesWedge",1.0);
AddColumn(Ascwedge AND trendlineS>50 AND RSI()>50,"Probable Bearish Breakout",1.0);
AddColumn(Descwedge AND trendlineR<50 AND RSI()<50,"Probable Bullish Breakout",1.0);
/* END of code */
_SECTION_END();
_SECTION_BEGIN("RSI Trendlines and Wedges");
SetChartOptions(0,0,chartGrid30|chartGrid70);
periods = Param( "Periods", 14, 1, 200, 1 );
Plot( RSI( periods), _DEFAULT_NAME(), ParamColor( "Color", colorlightblue ), ParamStyle("Style",styleThick) );
/*RSI Trendlines and Wedges*/
G=0;// set G=1, 2, 3, ... to see previous Resistance trendlines
GG=0;// set G=1, 2, 3, ... to see previous Support trendlines
x = Cum(1);
per = Param("Sensitivity",1,1,100,1); // sensitivity calibration
s1=RSI();s11=RSI();
pS = TroughBars( s1, per, 1 ) == 0;
endt= LastValue(ValueWhen( pS, x, 1+GG ));
startt=LastValue(ValueWhen( pS, x, 2+GG ));
dtS =endt-startt;
endS = LastValue(ValueWhen( pS, s1, 1+GG ) );
startS = LastValue( ValueWhen( pS, s1, 2+GG ));
aS = (endS-startS)/dtS;
bS = endS;
trendlineS = aS * ( x -endt ) + bS;// the Support trendline equation
Plot(IIf(x>startt-6 AND TRENDLINES>0 AND TRENDLINES<100,trendlineS,-1e10),"Support",IIf(as>0,5,4),8);
pR = PeakBars( s11, per, 1 ) == 0;
endt1= LastValue(ValueWhen( pR, x, 1+G ));
startt1=LastValue(ValueWhen( pR, x, 2+G ));
dtR =endt1-startt1;
endR = LastValue(ValueWhen( pR, s11, 1+G ) );
startR = LastValue( ValueWhen( pR, s11, 2 +G ));
aR = (endR-startR)/dtR;
bR = endR;
trendlineR = aR * ( x -endt1 ) + bR;// the Resistance trendline equation
Plot(IIf(x>startT1-6 AND TRENDLINER>0 AND TRENDLINER<100,trendlineR,-1e10),"Resistance",IIf(Ar>0,5,4),8);
Ascwedge=Ar>0.5 AND As>sqrt(2)*Ar AND trendlineR>trendlineS;
Descwedge= As<-0.5 AND As>Ar/sqrt(2) AND trendlineR>trendlineS;
Filter=1;
AddColumn(Ascwedge,"AscWedge",1.0);
AddColumn(DescWedge,"DesWedge",1.0);
AddColumn(Ascwedge AND trendlineS>50 AND RSI()>50,"Probable Bearish Breakout",1.0);
AddColumn(Descwedge AND trendlineR<50 AND RSI()<50,"Probable Bullish Breakout",1.0);
/* END of code */
_SECTION_END();
MainTrendLine_Diff = Param("Difference IND from MainTrendLine", 2.5, 0.5,7, 0.5);
d = starthigh ;
FirstDownSlope = (secondhigh - d) / (secondhighbar - starthighbar) ;
FirstDownTrendline = FirstDownSlope * ( BarIndex() - starthighbar ) + d;
SecondDownSlope = (thirdhigh - d) / (thirdhighbar - starthighbar) ;
SecondDownTrendline = SecondDownSlope * ( BarIndex() - starthighbar ) + d;
ThirdDownSlope = (fourthhigh - d) / (fourthhighbar - starthighbar) ;
ThirdDownTrendline = ThirdDownSlope * ( BarIndex() - starthighbar ) + d;
FourthDownSlope = (fifthhigh - d) / (fifthhighbar - starthighbar) ;
FourthDownTrendline = FourthDownSlope * ( BarIndex() - starthighbar ) + d;
FifthDownSlope = (sixthhigh - d) / (sixthhighbar - starthighbar) ;
FifthDownTrendline = FifthDownSlope * ( BarIndex() - starthighbar ) + d;
MainDownSlope = IIf( FirstDownSlope < SecondDownSlope, IIf( SecondDownSlope < ThirdDownSlope,
IIf( ThirdDownSlope < FourthDownSlope, IIf( FourthDownSlope < FifthDownSlope, FifthDownSlope, FourthDownSlope),ThirdDownSlope), SecondDownSlope), FirstDownSlope) ;
MainDownLine = IIf( MainDownSlope == 0, Null, MainDownSlope * ( BarIndex() - starthighbar ) + d ) ;
Plot( IIf( BarIndex() >= starthighbar, MainDownLine, Null ) , "Main_DOWN_Line", colorViolet, styleThick ) ;
IND_Diff = IIf( BarIndex() >= starthighbar, abs( IND - MainDownLine), Null) ;
Cond_Sell = IIf( BarIndex() >= Thirdbar AND IND_Diff <= MainTrendLine_Diff, IND, 0) AND MainDownLine > 45 ;
PlotShapes( IIf( Cond_Sell, shapeDownArrow , shapeNone ), colorRed );
Filter=Cond_buy OR Cond_sell;
AddColumn(IIf(Cond_buy,Close,Null)," Buy ", 6.2,1.2,colorGreen);
AddColumn(IIf(Cond_sell,Close,Null)," Sell ",6.2,1.2,colorOrange);