- Joined
- 13 January 2013
- Posts
- 258
- Reactions
- 50
The solution I came up with is as follows:
It only gives the right answer at the right-most bar. Is there a way to stop the plot from 'jumping' around? I would like to overlay the plot on a price chart.
Code:
_SECTION_BEGIN( "ArrayHL" );
function ArrayHL( Periods )
{
customArray = 0;
j = BarCount - 1;
for ( i = BarCount - 1; i >= 0; i-- )
{
if ( j < 2 * Periods )
break;
for ( count = 0; count <= Periods; count++ )
{
customArray[ j ] = H[ i - count ];
j--;
customArray[ j ] = L[ i - count ];
j--;
}
}
return CustomArray;
}
_SECTION_END();
_SECTION_BEGIN( "PercentileHL" );
Periods = Param( "Periods", 3, 1, 20, 1 );
Percent = Param( "Percentile (%)", 50, 0, 100, 5 );
Array = ArrayHL( Periods );
PA = Percentile( Array, 2 * Periods, Percent );
Plot( PA, "PercentileHL", colorRed, styleLine );
_SECTION_END();
It only gives the right answer at the right-most bar. Is there a way to stop the plot from 'jumping' around? I would like to overlay the plot on a price chart.