// Downloaded From https://www.WiseStockTrader.com
n=89; Av=23; stp=9;
n = Param("Periods",n,20,190,1);
av = Param("Average",av,2,30,1);
//n = Optimize("Periods",n,20,190,1);
//av = Optimize("Average",av,2,30,1);
stp = Optimize("Stop",stp,4,15,1);

RR= (C-MA(C,n))/EMA(ATR(1),n);

Plot( RR, "RR (" +WriteVal( n, 1.0 )+")" , 5, 5 );
Plot( 3, "" , 5, styleDashed );
Plot( -3, "" , 4, styleDashed );

RRAVG=MA(RR,av);

Plot(RRAVG,"AVG"+"("+WriteVal(Av, 1.0 )+")" ,colorRed,styleDots,styleDashed); 

Buy=Cross(RR,3);
Sell=Cross(0,RR);

////////////////////////////////////////////////////////////////

TD1 = ParamToggle("DAY","Hide|Show",1);
if(TD1==1) {
acc = Param("Acceleration", 0.08, 0, 1, 0.001 );
accm = Param("Max. acceleration", 0.2, 0, 1, 0.001 );
 
// Vertical Daily Segment
segments = IIf( Interval() < inDaily, Day(), Month() );
segments = segments != Ref( segments , -1 );
Plot( segments, "", colorGold, styleHistogram | styleOwnScale | styleDashed | styleNoLabel );
 
Volbar = TimeFrameGetPrice( "V", in1Minute * 20, 0 );
_TRACE( "Volbar = " + Volbar );
 
// Seconds Remaining
}

_SECTION_BEGIN("Ribbon");

Tr2 = Ref(C,1);
Tr3=Ref(C,8);
Trend2 = MA(Tr2,8);
Trend3=MA(Tr3,8);
Slope1=((Trend3-Trend2)/Trend3)*100;
//Plot(Slope1,"Buy When it is Green and Sell when it is Red or Pink",colorGold,styleLine+styleDots|styleThick);
 
 
Tr4 = Ref(C,8);
Tr5=Ref(C,13);
Trend3 = MA(Tr4,13);
Trend4=MA(Tr5,13);
Slope2=((Trend4-Trend3)/Trend4)*100;
Buy= nwbull=slope1 > 0 AND slope2 > 0 ;
Sell=nwbear=slope1 < 0 AND slope2 < 0 ;
 Plot( 1, /*efines the height of the ribbon in percent of pane width */"ribbon",
 IIf( nwbull, colorLime, IIf( nwbear, colorRed,IIf(Signal()<MACD(), colorPink, colorPink ))), /* choose color */
 styleOwnScale|styleArea|styleNoLabel, 0, 50 );
_SECTION_END();


SetChartBkColor(ParamColor("Background Color", colorBlack));


GraphXSpace = Param("GraphXSpace",18,-35,20,0.5);