Help requierd for creating Ribbon in woodie

I need help in the AFL code i want to make an uptrend start - -end till the start of the downtrend based on Woodie so that I can take this code to on smaller time version . From the Yellow square to till appearance of black square it should print a Green ribbon and From the Black square to the yellow square it start of down trend.

_SECTION_BEGIN("Price");
SetChartOptions(0,chartShowArrows|chartShowDates);
_N(Title = StrFormat("{{NAME}} - {{INTERVAL}} {{DATE}} Open %g, Hi %g, Lo %g, Close %g (%.1f%%) Vol " +WriteVal( V, 1.0 ) +" {{VALUES}}", O, H, L, C, SelectedValue( ROC( C, 1 )) ));
Plot( C, "Close", ParamColor("Color", colorDefault ), styleNoTitle | ParamStyle("Style") | GetPriceStyle() ); 
_SECTION_END();

_SECTION_BEGIN("Breakout");
 Buyperiods=Param("Breakout periods best is usually 18",5,1,100,1,1);
 Sellperiods=Param("Exit Breakout",5,1,100,1,1);

 HaClose =EMA((O+H+L+C)/4,3); // Woodie 
 //HaClose =(O+H+L+C)/4; 
 HaOpen = AMA( Ref( HaClose, -1 ), 0.5 ); 
 HaHigh = Max( H, Max( HaClose, HaOpen ) ); 
 HaLow = Min( L, Min( HaClose, HaOpen ) ); 
 Buy= C>Ref(HHV(High,Buyperiods),-1) ;
 Sell= C<Ref(LLV(Low,Sellperiods),-1);

 /* exrem is one method to remove surplus strade signals. It removes excessive signals of arrow */
 Buy = ExRem(Buy, Sell);
 Sell = ExRem(Sell, Buy);

 PlotShapes( IIf( Buy, shapeSmallSquare, shapeNone ), colorYellow, layer = 0,yposition = HaLow, offset = -30);


 PlotShapes( IIf( Sell, shapeSquare, shapeNone ), colorBlack, layer = 0, yposition = HaHigh, offset = -30);


 _SECTION_END();

@Sam1

From the Yellow square to till appearance of black square it should print a Green ribbon and From the Black square to the yellow square it start of down trend.

It is not clear what you want to see from Black to Yellow....
Anyway, try adding these lines to your code

inTrade = Flip( Buy, Sell );
ribbonColor = iif( inTrade, colorGreen, colorRed );
Plot( 2, "", ribbonColor , styleArea | styleOwnScale | styleNoTitle | styleNoLabel, 0, 100 );