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

Re: Divergence Coding



PureBytes Links

Trading Reference Links

Dave
The formula looks good but i have seen that divergence only last's for
one day before the RSI and momentum become the same rate of
Linear Regression Slope so the formula is in to long of a time frame
or am I wrong ?
I have been using this momentum indicator to compare it with the
RSI have a look try it out.  : Good trading!     Jo...

{momentum oscillator  GRII}
(TSF(C,9)-Ref(TSF(C,9),-1))+((Ref(TSF(C,9),-1)-
Ref(TSF(C,9),-2)))+((Ref(TSF(C,9),-2)-(Ref(TSF(C,9),-3))))
___________________________________________________
Dave Nadeau wrote:

> John,
>
> Below is a first pass at the Linear Regression Slope code for the Divergence
> indicator:
>
> LC30:=LinRegSlope(C,30);
> LI30:=LinRegSlope(RSI(9),30);
> AA30:=(LC30>0 AND LI30<0);
> BB30:=(LC30-LI30)-Ref((LC30-LI30),-1)>0;
> LC60:=LinRegSlope(C,60);
> LI60:=LinRegSlope(RSI(9),60);
> AA60:=(LC60>0 AND LI60<0);
> BB60:=(LC60-LI60)-Ref((LC60-LI60),-1)>0;
> AA30 AND AA60 AND Sum(BB60,3)=3 AND Sum(BB30,3)=3
>
> I've limited this to looking for negative divergences on rising closing prices.
> For the other three possibilities, the changes would be "cut and paste" from the
> above with some > or <  comparsion changes.
>
> In the code above, I'm looking for positive price slope with negative RSI(9)
> slope.  I'm also requiring that the difference between the two has been
> increasing for the last three periods.  I do this for both the 60 period slopes
> and the thirty period slopes.  Then I'm requiring the test to be true for both
> cases.  The result of this formula will be a 1 when a divergence exists.
>
> Some arbitrary values used above that need to be experimented with or changed
> based on preference.  "3" periods of widening divergence, "60" and "30" periods
> for slope comparison, RSI using "9" periods.
>
> I've 'eyeballed' this on a daily chart or two, and it seems to call out
> divergences.  The next step would be to take the HHV of the last x periods and
> compare it with the same for 30 or 40 periods before.  Select only those with a
> comparative difference of some chosen percentage.  (e.g.  The HHV of the close
> is within 3% of the prior HHV 30 periods ago, but the HHV of the RSI(9) is more
> than 10% different from its HHV 30 periods ago).
>
> That filter should help limit some of the above divergence signals and make it
> more reliable.
>
> Dave Nadeau
> Fort Collins, CO
>
> John Adair wrote:
>
> > Hi Dave
> > I like your suggestion for llinear regression to pick up divergence. Yes
> > lets you try to code it for us.
> >
> > -----Original Message-----
> > From: owner-metastock@xxxxxxxxxxxxx
> > [mailto:owner-metastock@xxxxxxxxxxxxx]On Behalf Of Dave Nadeau
> > Sent: Saturday, December 02, 2000 5:36 PM
> > To: metastock@xxxxxxxxxxxxx
> > Subject: Re: Divergence
> >
> > John,
> >
> > I haven't coded this and run it out yet, but here's what I'd try:
> >
> > I would combine a comparison of Linear Regression Slope with the HHV (or
> > LLV's)
> > for different periods of time.  Using 1 to 70 periods as you suggest, I'd
> > probably first screen for those tickers which have made new highs (or lows)
> > in
> > the last 20 periods, or last 20-40 periods.  Then I'd compare the
> > LinRegSlope of
> > the prices with the LinRegSlope of the RSI.  I'd then subtract the two and
> > eliminate any difference less than some threshold (say 0.5 or
> > 1.0--experiment
> > with the results to find the right amount).  I'd probably take it a step
> > further
> > and compare the LinRegSlope of 70 periods with say 30 periods then 10
> > periods of
> > each series, just to narrow down the pattern.
> >
> > Once I've established a divergence in slope, I'd then compare the recent
> > HHV(of
> > say the last 20 periods) with the HHV of the 20-40 bars ago period with the
> > 40-70 bars ago period.  For a negative divergence, I'd want HHV1, HHV2, and
> > HHV3
> > of the prices to be constant or increasing, while those of the indicator
> > should
> > be decreasing.  ...and just the opposite for a positive divergence.
> >
> > If anyone on the list is interested in the actual coding of this, we can
> > keep
> > the thread alive and post some Metastock Formula Language.  Or try some
> > other
> > approaches.
> >
> > Dave Nadeau
> > Fort Collins, CO
> >
> > jhmtn wrote:
> >
> > > One of the more interesting indicators of price reversal for me is the
> > > divergence that occurs between a momentum indicator and the price action.
> > > For example, if through some time period both price and RSI make a high
> > and
> > > then price rises and RSI drops, then divergence has occured between the
> > > indicator and the price and a reversal in price action "might" occur.
> > >
> > > I have not been able to figure out a manner of looping thru the past 1 to
> > 70
> > > periods of price and momentum indicator values to figure out if the prices
> > > are showing divergences or not using Metastock.
> > >
> > > Does anyone have such a formula or know where i can find it?
> > >
> > > Thanks. ................................... John