@thankyou18, I like the exploration as a tool to visualize array contents.
For instance, here below is an exploration formula using the @fxshrat's function (modified only to make it more generic accepting an array as the first parameter):
// Function based on @fxshrat code posted here:
// https://forum.amibroker.com/t/how-to-make-convert-this-long-assignment-statement-into-a-function/7181/3
function get_num_times_above( array, n )
{
num_times_above = 0;
refn = Ref( array, -n );
for( i = 0; i < n; i++ )
num_times_above += Ref( array, -i ) > refn;
return num_times_above;
}
n = Param( "N. of the past element to reference", 4, 3, 15, 1 );
O_nta = get_num_times_above( O, n );
H_nta = get_num_times_above( H, n );
L_nta = get_num_times_above( L, n );
C_nta = get_num_times_above( C, n );
X_nta = O_nta + H_nta + L_nta + C_nta;
// Exploration sample
function getColor( a, n )
{
return( IIf( a, ColorHSB( ( 32 + ( a / n ) * 32 ), 255, 255 ), colorDefault ) );
}
function getHeader( aName, n )
{
return ( StrFormat( "%s... > Ref(%s, -%1.0f)", aName, aName, n ) );
}
Filter = 1;
AddColumn( O_nta, getHeader( "O", n ), 1, colorDefault, getColor( O_nta, n ) );
AddColumn( H_nta, getHeader( "H", n ), 1, colorDefault, getColor( H_nta, n ) );
AddColumn( L_nta, getHeader( "L", n ), 1, colorDefault, getColor( L_nta, n ) );
AddColumn( C_nta, getHeader( "C", n ), 1, colorDefault, getColor( C_nta, n ) );
AddColumn( X_nta, getHeader( "All", n ), 1, colorDefault, getColor( X_nta, n * 4 ) );
SetSortColumns( -2 ); // see most recent quotes first
Perhaps, here, it is fancier than needed, but sometimes it can be a useful alternative to the charts to examine the used arrays values.