This page contains all necessary information that you require, specifically this code taken from there.
New parameters make it also easy to plot ribbons, for example:
Plot( Close, "Price", colorBlue, styleCandle );
Plot( 2, /* defines the height of the ribbon in percent of pane width */
"Ribbon",
IIf( up, colorGreen, IIf( down, colorRed, 0 )), /* choose color */
styleOwnScale|styleArea|styleNoLabel, -0.5, 100 );
As suggested by John to solve your requirements hope this example helps:
_SECTION_BEGIN( "Ribbon of Blocks" );
per = Param( "Average Period", 21, 3, 144, 1 );
MovAv = MA( Avg, per );
up = C > MovAv;
down = C < MovAv;
BlockColor = IIf( up, colorGreen, IIf( down, colorRed, colorBlue ) );
Plot( Close, "Price", colorDefault, styleCandle );
Plot( MovAv, "MovAv", colorWhite, styleThick );
SetBarFillColor( BlockColor );
PlotOHLC( 0, 2, 0, 2, "", colorDefault, styleOwnScale | styleCandle, -0.5, 100 );
_SECTION_END();