Your code works.
However, there are a few minor errors:
1. You compute
the HHVMax (C) and LLVMin(C) rather than HHVMax (H) and LLVMin(L),
which can cause some overlap
2. In the
presence of RHS blank bars an error message appears.
3. Since AB 5.25 (I believe) there are two undocumented functions HighestVisibleValue() and LowestVisibleValue();
They replace:
fvb = Status("firstvisiblebar");
lvb = Status("lastvisiblebar");
HHVMax=0; LLVMin=10000;
for( i = fvb; i <= Lvb; i++ )
{
HHVMax=Max(H[ i ],HHVMax);
LLVMin=Min(L[ i ],LLVMin);
}
with
HHVmax=HighestVisibleValue(H);
LLVMin=LowestVisibleValue(L);
Use of those functions reduces the code
to (and takes care of the array out of range error message):
//=====================Simplified using
new functions and without loops=================
PercZoneLow1 = Param("PercZoneLow1",0.3,0.000001,1,0.05) ;
PercZoneHigh1 = Param("PercZoneHigh1
",1,0.000001,1,0.05) ;
PercZoneLow2 = Param("PercZoneLow2",0.00001,0.000001,1,0.05) ;
PercZoneHigh2 = PercZoneLow1 ;
al = ATR(14);
HHVmax=HighestVisibleValue(H);
LLVMin=LowestVisibleValue(L);
almax=HighestVisibleValue(al);
alMin=LowestVisibleValue(al);
MinZ1 = ( PercZoneLow1 * HHVMax -
PercZoneHigh1 * LLVMin ) / ( PercZoneLow1 - PercZoneHigh1 );
MaxZ1 = ( LLVMin - MinZ1 ) /
PercZoneLow1 + MinZ1;
MinZ2 = ( PercZoneLow2 * almax-
PercZoneHigh2 * alMin) / ( PercZoneLow2 - PercZoneHigh2 );
MaxZ2 = ( alMin- MinZ2 ) / PercZoneLow2
+ MinZ2;
Plot( C, "C in
zone", colorBlack, styleCandle | styleOwnScale,
MinZ1, MaxZ1);
Plot( al, "ATR(14) in zone", colorRed,
styleLine | styleOwnScale,MinZ2, MaxZ2);
//===============================================================================
Also takes care of the array out of
range error message.
From:
amibroker@xxxxxxxxxxxxxxx [mailto:amibroker@xxxxxxxxxxxxxxx] On Behalf Of Bisto
Sent: Tuesday, November 17, 2009 3:36 PM
To: amibroker@xxxxxxxxxxxxxxx
Subject: [amibroker] Re: Is it possible to divide an indicator pane into
several zones?
You are right!
I don't use blank bars at the right indeed, so I never noticed it before
if you set them at 0 it works
I will appreciate if you'll keep me informed if you change the code to solve
this bug
Bisto
--- In amibroker@xxxxxxxxxxxxxxx,
"Anthony Faragasso" <ajf1111@xxx>
wrote:
>
> Hello,
>
> I believe it is because if you have blank bars to the right of the last
visible price...it produces error....
>
>
> ----- Original Message -----
> From: Bisto
> To: amibroker@xxxxxxxxxxxxxxx
> Sent: Tuesday, November 17, 2009 4:05 PM
> Subject: [amibroker] Re: Is it possible to divide an indicator pane into
several zones?
>
>
>
> 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 amibroker@xxxxxxxxxxxxxxx,
"Anthony Faragasso" <ajf1111@> wrote:
> >
> > Hello,
> >
> > Formula returns Subscript out of range error..
> >
>
No virus
found in this incoming message.
Checked by AVG - www.avg.com
Version: 8.5.425 / Virus Database: 270.14.67/2506 - Release Date: 11/16/09
07:43:00
__._,_.___
**** IMPORTANT PLEASE READ ****
This group is for the discussion between users only.
This is *NOT* technical support channel.
TO GET TECHNICAL SUPPORT send an e-mail directly to
SUPPORT {at} amibroker.com
TO SUBMIT SUGGESTIONS please use FEEDBACK CENTER at
http://www.amibroker.com/feedback/
(submissions sent via other channels won't be considered)
For NEW RELEASE ANNOUNCEMENTS and other news always check DEVLOG:
http://www.amibroker.com/devlog/
__,_._,___