Joe M.
usacoder
Raleigh, NC
Post #: 6
I am writing an app to test diverging values of a stock's price with an oscillator. Divergence being when the price and the oscillator are moving in opposite (up/down) directions.

Using a chart this is an easy process.

My first attempt at testing divergence was to take a moving average of both and if one is greater than its current m.a. while the other is less than its m.a. then a divergent event has occurred.
MA(price) > price & MA(oscillator) < oscillator
or
MA(price) < price and MA(oscillator) > oscillator

Can anyone find any fault in my algorithm?

TIA,

Joe McVerry
Prakash G.
user 10093921
Raleigh, NC
Post #: 103
Joe,

It is a good idea to test Divergence to see it yourself if it has any merit.
Divergence is one of the most talked about and most believed in kind of indicator.
Intuitively, it seems logical. But, only when you will test it yourself on hundreds of stocks for several years data, you will know if it really has any merit.

I did that myself, and I would say, it was one of the most tricky concept to code. It took me back to drawing board several times, till i got it right. It does not mean the indicator has merit, it just means I was able to code it to replicate Human Eye's detection of divergence in a chart (to a reasonable accuracy).

In back testing, I found no merit in it. I tested RSI/Stoch/Macd divergences. One at a time. Behind 1 successful divergence setup, there are 3 failed setups.
But testing it by our self and not taking anybody's word (For or against ) it is important.

Coming back to your idea of detecting divergence: nobody can say if it is correct or not, unless you code it.
the process is simple.
1. start with a idea on paper (just like you did)
2. code it and see divergence detected on chart by the code.
3. Using human eyes see the divergence on other chart.
4. see if the instances of step2 and step3 matches. If it matches at several times in several charts, your idea is right.
5. If not, start with new idea to detect divergence in step 1 and repeat. :-)
6. Once you get it right, back test it. It is very important than believing the stuff that is thrown at us.

btw, if you just want to scan for divergence, Finviz may have it.
http://finviz.com/...­

Here are some links of code that other people tried to detect divergence.

http://www.amibroker....­

http://www.wisestockt...­

http://www.marketcall...­


Regards,
Prakash.



Dr. Jose' R.
Skeptic
Cary, NC
Post #: 682
Prakash, that's a great response. One of the best contributions I have seen. It is objective, factual, pointing out your own valuable results.

Thanks!

Jose'
Don B.
DonBrady
Group Organizer
Cary, NC
Post #: 1,005
I think that the underlying difficulty is that all price-based oscillators behave very similarly, and that looking for patterns in their relationship to price is basically looking for patterns in derivatives of derivatives. If the market is anywhere near efficient, this may not be fruitful.

Certainly any and all testing and research is excellent and we love to hear the results.

In a recent webinar, Jeff Augen, who has written "Trading Options at Expiration", and done extensive statistical studies of market behavior down to the tick level, said that many (maybe all) of the traditional patterns of technical analysis no longer have any predictive ability. He says that they used to in some cases, but no longer do. Their edge is being instantaneously arbitraged away over all time-frames (except maybe over very long time periods for a few simple ones).




Prakash G.
user 10093921
Raleigh, NC
Post #: 104
Thanks Jose' and Don.

<<basically looking for patterns in derivatives of derivatives.>>

may be that is not the case here with divergence.
http://stockcharts.co...­

all Technical indicators will have lag. So is macd as a indicator has lag. While looking for the divergence, we are comparing that lag with Price chart. Price chart (candle, bar or line) does not have any lag.
So basically we are looking for information that his hidden in the lag. Divergence is our angle here.

It seems very logical that this kind of approach will have merit. But we all know, logic it self has little merit in trading. ;-)

In Back testing my approach is to test the "principle under test" in it's purity. I mean i don't want to add anything else in to the equation. e.g. no set theory (baskets of stocks),no moving averages, no volatility, no volume analysis...nothing. Just pure divergence to be tested. By simple coin method we should get 50% right decisions. So I will expect much better results from trading using divergence. It can be compared with studies of other principles in purity.

<<many (maybe all) of the traditional patterns of technical analysis no longer have any predictive ability.>>

Don we are assuming here that, Divergence ever has any predictive ability. ;-)
From what i tested, i did not find it working ever in last 15 to 18 years. It never gave consistent positive results in history.

There is some good merit to what Jeff is saying. There was "some stuff" that used to work in past. and it has lost the edge in last 5 years or so. But divergence is not in that list. :-)

But we still keep on hearing so many good stories about Divergence. Let's say Mike is a good successful trader and he trades using Divergence. he has a website and all his historical trades are there along with charts and divergence setup marked. He call his system "Trading Stochastic Divergence".
What is happening actually is, Mike looks for divergence set ups. Then he look for some fundamentals of that company, pending news, the volume moves, candle sticks analysis, General market mood, MA lines, pending quarterly results etc. etc. Also mike has spent years trading and he is successful means he has risk management in place. His trading is successful.

I will call his system specifically, "Mike's stochastic Divergence". It works because it is "Mike's divergence system" and not because it is divergence. Within his system who knows what factors are contributing positively and what factors are contributing negatively? Unless we have tested each principle in it's purity?

summary:
Several good successful trades (especially those bottom/top picking) may have good divergence setup.
But each divergence setup will not lead to successful trade.


(It is just my individual opinion. So please don't be offended if you are successfully using divergence. If it is working for you, keep it up and discard anything anybody says.)

Regards,
Prakash.






Don B.
DonBrady
Group Organizer
Cary, NC
Post #: 1,006
Prakash,

That is outstanding that you have done such extensive testing!

I am doing some also and will report them in a few months (but centered more around options and trends).

Jeff Augen did not really say which technical indicators used to work according to his testing, and did not mention divergence in particular.


Don
Dr. Jose' R.
Skeptic
Cary, NC
Post #: 683
A critical assessment of statistical claims was given in the following example from a technical report by Savage (1961):

1) A lady who adds milk to her tea claims to be able to tell whether the milk or the tea was added to the cup first. In 10 trials conducted to verify her claim, she is successful in all 10 trials.

2) A music expert claims to be able to distinguish between a page of Haydn score from a page of Mozart's score. In all 10 trials he successfully distinguishes the correct score.

3) A drunkard claims to be able to predict the outcome of a flip of a fair coin. In 10 trials (conducted while he is most drunk), he is correct every single time.

One's views on whether the test results reveal that the claims were valid or whether the trial results are the results of lucky streaks, are very much influenced by our PRIOR information and beliefs (I hope we agree at least, on the case of the drunkard :-), unless one contemplates that he has extra-sensory perception).

Therefore, I doubt that discussions on whether claims of success using technical indicators are valid or not will ever be settled (although I do have strong opinions on this matter, due to prior information and beliefs) :-)
Joe M.
usacoder
Raleigh, NC
Post #: 7
Prakash,

Thank you for your comments and the links. All of this may help as I delve into this problem.

The divergence test if for a program based on the William's Ultimate Oscillator.

Joe
Don B.
DonBrady
Group Organizer
Cary, NC
Post #: 1,007
Here is a link to information on Larry Williams' own site on computing Larry Wiliams' Ultimate Oscillator:

http://www.ireallytra...­
Powered by mvnForum

Sign up

Meetup members, Log in

By clicking "Sign up" or "Sign up using Facebook", you confirm that you accept our Terms of Service & Privacy Policy