I post it again with copy & paste from AB where it's running ok... who knows?


function MinZone( array, PercZoneLow, PercZoneHigh )
{
    fvb = Status( "firstvisiblebar" );
    lvb = Status( "lastvisiblebar" );
    HHVMax = -100000000;
    LLVMin = 100000000;

    for ( i = fvb; i <= Lvb; i++ )
    {
        HHVMax = Max( array[ i ], HHVMax );
        LLVMin = Min( array[ i ], LLVMin );
    }

    MinZ = ( PercZoneLow * HHVMax - PercZoneHigh * LLVMin ) / ( PercZoneLow - 
PercZoneHigh );

    return MinZ ;
}

function MaxZone( array, PercZoneLow, PercZoneHigh )
{
    fvb = Status( "firstvisiblebar" );
    lvb = Status( "lastvisiblebar" );
    HHVMax = -100000000;
    LLVMin = 100000000;

    for ( i = fvb; i <= Lvb; i++ )
    {
        HHVMax = Max( array[ i ], HHVMax );
        LLVMin = Min( array[ i ], LLVMin );
    }

    MinZ = ( PercZoneLow * HHVMax - PercZoneHigh * LLVMin ) / ( PercZoneLow - 
PercZoneHigh );

    MaxZ = ( LLVMin - MinZ ) / PercZoneLow + MinZ;

    return MaxZ ;
}


// example: use the above functions to define min and max values of 
styleownscale

// please note that axes type has to be linear (logartimic type requests little 
modification in the code)
// please also note that plot style has to be ALSO styleOwnScale

PercZoneLow1 = Param("PercZoneLow1",0.3,0.000001,1,0.05) ;
PercZoneHigh1 = Param("PercZoneHigh1 ",1,0.000001,1,0.05) ;

Plot( C, "C in zone", colorBlack, styleCandle | styleOwnScale, 
MinZone(C,PercZoneLow1,PercZoneHigh1), MaxZone(C,PercZoneLow1,PercZoneHigh1));

PercZoneLow2 = Param("PercZoneLow2",0.00001,0.000001,1,0.05) ;
PercZoneHigh2 = PercZoneLow1 ;

// in case of time consuming array avoid to calculate 3 times
arraylongtobecalculated = al = ATR(14);

Plot( al, "ATR(14) in zone", colorRed, styleLine | styleOwnScale, 
MinZone(al,PercZoneLow2,PercZoneHigh2), MaxZone(al,PercZoneLow2,PercZoneHigh2));



--- In [email protected], "Anthony Faragasso" <ajf1...@...> wrote:
>
> Hello,
> 
> Formula returns Subscript out of range error..
> 


Reply via email to