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

[amibroker] Dynamic Cycle Length Based Stoch Oscillator



PureBytes Links

Trading Reference Links

Thanks Johan for providing the basis of this
indicator. 

This is not the holy grail or some magical stuff. It
is just more effective. Based on the cycle lengths
enumerated by J. M. Hurst in his book "The Profit
Magic of Stock Market Timing I have settled for a
nominal cycle length of 13 weeks(quarter of a year or
65 trading days). If the actual cycle length exceeds
65 trading days, then the actual cycle length is used.
The cycle length is taken as the distance(number of
bars) between the two lowest lows made when the MACD
is below 0. 

I again repeat this is not a fancy indicator. Just the
same old Stochastic. Hope it is found to be of use by
those interested in cycle related work.

Regards


Rakesh

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

function LOWESTBetween( _expression, array, n )
//Returns the lowest 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 );
}




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




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

LP2 = LowestBetween( k_D, L, 1 );
LPB2 = bar+1;


CYCLE_LENGTH=LPB1-LPB2;
CYCLE_LENGTH=IIf(CYCLE_LENGTH>65,CYCLE_LENGTH,65);

STOCH_KNUM=LastValue(CYCLE_LENGTH/2);
STOCH_SLNUM=LastValue(STOCH_KNUM*0.5);
STOCH_DNUM=IIf(LastValue(STOCH_KNUM*0.2)<3,3,STOCH_KNUM*0.2);
STK_K=StochK(STOCH_KNUM,STOCH_SLNUM);
STK_D=EMA(STK_K,STOCH_DNUM);


Plot(STK_K,"STK_K",colorRed);
Plot(STK_D,"STK_D",colorBlue);


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

__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 


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/