[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [amibroker] highestsincebars



PureBytes Links

Trading Reference Links

The answer you probably need was kindly provided to me a group member
JohSun(I hope I have his ID right).

The code is pasted below
===================

function LOWESTBetween( _expression, array, n )
//Returns the highest ARRAY value between the Nth most recent
//occurrence of True _EXPRESSION and the one prior to that.
{
  global bar;
  bx = BarIndex();
  e = _expression;
  a = array;

  Ls  = LowestSince( e, a );
  Lsb = LowestSinceBars( e, a );

  Lb  = IIf( n, ValueWhen( e, Ref( Ls, - 1 ), n ), Ls );
  bar = IIf( n, ValueWhen( e, bx - Ref( Lsb, - 1 ), n ) - 1,
        bx - Lsb );

  bar = LastValue( bar );

  return LastValue( Lb );
}

===================

function HIGHESTBetween( _expression, array, n )
//Returns the highest ARRAY value between the Nth most recent
//occurrence of True _EXPRESSION and the one prior to that.
{
  global bar;
  bx = BarIndex();
  e = _expression;
  a = array;

  Hs  =HighestSince( e, a );
  Hsb = HighestSinceBars( e, a );

  Hb  = IIf( n, ValueWhen( e, Ref( Hs, - 1 ), n ), Hs );
  bar = IIf( n, ValueWhen( e, bx - Ref( Hsb, - 1 ), n ) - 1,
        bx - Hsb );

  bar = LastValue( bar );

  return LastValue( Hb );
}

===================

Example of use:

Dk_D = Cross(0,MACD() );
DK_U = Cross( MACD(),0 );
Occ=Param("occ",0,0,10);


LP1 = LowestBetween( Dk_D, L, 0 );
LPB1 = bar+1;
===================


Hope that helps.



R


On 8/13/06, Terry <MagicTH@xxxxxxxxxxx> wrote:
> Michael,
>
> Try this:
>
>     Result = Ref(HHV(H,100),-100);
>
> This avoids absolute references and works for all bars giving you the
> highest high of the 100 previous bars starting 100 bars ago. (thus in
> your example, it's from 100-200).
> --
> Terry
> -----Original Message-----
> From: amibroker@xxxxxxxxxxxxxxx [mailto:amibroker@xxxxxxxxxxxxxxx] On
> Behalf Of Michael.S.G.
> Sent: Saturday, August 12, 2006 21:07
> To: amibroker@xxxxxxxxxxxxxxx
> Subject: [amibroker] highestsincebars
>
> I'm tring to plot a line array using the highest high within a range of
> bars.
>
> I can locate the highest since a particular bar, But I don't want to
> look beyond a certain bar.
>
> eg
> Total bars = 0-300.
> I only want to find highest high from between bars 100-200.
>
> Anyone know how to do this?
>
>
>
>
> Please note that this group is for discussion between users only.
>
> To get support from AmiBroker please send an e-mail directly to
> SUPPORT {at} amibroker.com
>
> For other support material please check also:
> http://www.amibroker.com/support.html
>
>
> Yahoo! Groups Links
>
>
>
>
>
>
>
>
>
> Please note that this group is for discussion between users only.
>
> To get support from AmiBroker please send an e-mail directly to
> SUPPORT {at} amibroker.com
>
> For other support material please check also:
> http://www.amibroker.com/support.html
>
>
> Yahoo! Groups Links
>
>
>
>
>
>
>