I found this below afl , it is an interesting one, kindly please how to add code to calculate the percentage of hhl/llv per box. e.g : first box percentage , second box percentage and so on and finally get the average of all box percentage.
Kind regards
/* Boxes, E.M.Pottasch, Apr 2017 */
//Version( 6.21 );
GfxSetZOrder( -5 );
GfxSetCoordsMode( 1 );
bi = BarIndex();
fvb = FirstVisibleValue( bi );
lvb = LastVisibleValue( bi );
GraphXSpace = 5;
SetChartBkColor( ColorRGB( 0, 0, 0 ) );
SetChartOptions( 1, chartShowDates, chartGridMiddle, 0, 0, 0 );
SetBarFillColor( IIf( C > O, ColorRGB( 0, 75, 0 ), IIf( C <= O, ColorRGB( 75, 0, 0 ), colorLightGrey ) ) );
Plot( C, "", IIf( C > O, ColorRGB( 0, 255, 0 ), IIf( C <= O, ColorRGB( 255, 0, 0 ), colorLightGrey ) ), 64, Null, Null, 0, 0, 1 );
_SECTION_BEGIN( "Box" );
BoxWidth = Param( "Box Width", 5, 1, 50, 1 );
nBox = Param( "Number of Boxes", 5, 1, 100, 1 );
_SECTION_END();
ymax = HHV( H, BoxWidth );
ymin = LLV( L, BoxWidth );
function drawBoxes()
{
GfxSetZOrder( 1 );
cnt = 0;
for( i = lvb; i > fvb; i = i - BoxWidth )
{
if( cnt < nBox )
{
GfxSelectPen( coloryellow, 1, 0 );
x1 = i - ( BoxWidth - 1 ) - 0.5;
x2 = i + 0.5;
y1 = ymax[i];
y2 = ymin[i];
GfxPolyLine( x1, y1, x1, y2, x2, y2, x2, y1, x1, y1 );
cnt = cnt + 1;
}
if( cnt > nBox ) break;
}
}
drawBoxes();