// Downloaded From https://www.WiseStockTrader.com
_SECTION_BEGIN("trend with pivot levels");
_N(Title = StrFormat("{{NAME}} - {{INTERVAL}} {{DATE}} Open %g, Hi %g, Lo %g, Close %g (%.1f%%) {{VALUES}}", O, H, L, C, SelectedValue( ROC( C, 1 ) ) ));
TimeFrameSet(inDaily);
wc=C;
TimeFrameRestore();
uptrend= Signal(18)<MACD(7);
downtrend= Signal(18)>MACD(7);
PRSI=RSI(14)>55 ;
NRSI=RSI(14)<45 ;
Plot( 2, /* defines the height of the ribbon in percent of pane width */"ribbon",
IIf( PRSI, colorGreen, IIf( NRSI, colorRed, 0 )), /* choose color */
styleOwnScale|styleArea|styleNoLabel, -0.5, 100 );


_SECTION_BEGIN("Chart");
MASK= ParamStyle("MASK",styleCandle| styleThick , maskAll);
barcolor=IIf(UPTREND,colorGreen,IIf(doWNTREND,colorRed,colorBlue));
Plot(C, "C", barcolor,MASK);

A=C>MA(C,50) ;
B=C<MA(C,50) ;
Plot( 2, /* defines the height of the ribbon in percent of pane width */"ribbon",
IIf( A, colorGreen, IIf( B, colorRed, 0 )), /* choose color */
styleOwnScale|styleArea|styleNoLabel, -0.5, 100 );
_SECTION_END();

_SECTION_BEGIN("MA 50");
A=C>MA(C,50) ;
B=C<MA(C,50) ;
Plot( 4, /* defines the height of the ribbon in percent of pane width */"ribbon",
IIf( A, colorBlue, IIf( B, colorRed, 0 )), /* choose color */
styleOwnScale|styleArea|styleNoLabel, -0.5, 100 );
_SECTION_END();

Buy=UPTREND AND C>O AND C>Ref(C,-1) AND C>(H+L)/2 AND V>Ref(V,-1);// AND H>wc;
Short=doWNTREND AND C<O AND C<Ref(C,-1) AND C<(H+L)/2 AND V>Ref(V,-1) ;//AND L<wc;
Sell=downtrend;
Cover=prsi OR uptrend;
Buy=ExRem(Buy,Sell);
Sell=ExRem(Sell,Buy);
Short=ExRem(Short,Cover);
Cover=ExRem(Cover,Short);
ribboncol= IIf(Buy, colorGreen, colorRed );

PlotShapes( Buy + 2 * Sell, ribboncol, 0, IIf( Buy, L, H ), -10 );
PlotShapes( IIf( Cover, shapeUpArrow, shapeNone ),10,0,L,-25  ); 
PlotShapes( IIf( Short, shapeDownArrow, shapeNone ),13,0,H,-25  );