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

[amibroker] Re: Highest and Lowest Between two events and bar # when such hi/los' occur



PureBytes Links

Trading Reference Links

Rakesh,

I've seen your request for this before, and I intended to take a 
look at it but never got round to it.
 
But now I have some code for you...

The global variable bar holds the barindex. Keep in mind that if you 
call the function more than once 
you must assign this value to a new variable since subsequent 
function calls will overwrite it.

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 ---

m = MACD();
k = Cross( m, 0 );

x0 = HighestBetween( k, m, 0 );
bar0 = bar;

x1 = HighestBetween( k, m, 1 );
bar1 = bar;

Plot( m, "", colorRed, styleLine );
Plot( x0, "barindex " + bar0 , colorBlue, styleLine );
Plot( x1, "barindex " + bar1 , colorGreen, styleLine );



Regards,
Johan

--- In amibroker@xxxxxxxxxxxxxxx, "rakeshsahgal" <rakeshsahgal@xxxx> 
wrote:
> If there is any interest in such a function I request interested 
group
> members to please ask for the same from TJ.
> 
> I have had reasonable amount of  success in identifying pivots 
using
> this method. If we can also get the bar numbers when such highs and
> lows occur it would help in creating much more effective 
trendlines to
> depict support/resistance and compute cycle lengths.
> 
> If there is a better method than the one I am advocating I will be
> most grateful to anyone who can point the same out to me. If not, 
do
> take the trouble of writing to TJ and request the inclusion of this
> feature. Thanks and Regards,
> 
> 
> Rakesh




------------------------ Yahoo! Groups Sponsor --------------------~--> 
What would our lives be like without music, dance, and theater?
Donate or volunteer in the arts today at Network for Good!
http://us.click.yahoo.com/Tcy2bD/SOnJAA/cosFAA/GHeqlB/TM
--------------------------------------------------------------------~-> 

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

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/amibroker/

<*> To unsubscribe from this group, send an email to:
    amibroker-unsubscribe@xxxxxxxxxxxxxxx

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/