Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
Divergence of price and indicators

Hi, I am a newbie and trying to learn the platform. I am looking for library which tell us the divergence of the stock price and any of the indicators. Do we have any such library/functions ?

Basically I need to know whether the price momentum is going up/down and the indicator (say RSI) is going up/down. Usually divergence is one of the strong indicator and I am try to implement and see how it works. Any help is much appreciated. Thanks.

4 responses

Uvaraj,

Glad to see you're learning! Do you have an idea of how you would want to test for divergence or provide some more detail on some other methods that exist? I don't believe a preset library exists for something like this although you may check out Numpy (http://www.numpy.org/).

-Seong

Disclaimer

The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by Quantopian. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. No information contained herein should be regarded as a suggestion to engage in or refrain from any investment-related course of action as none of Quantopian nor any of its affiliates is undertaking to provide investment advice, act as an adviser to any plan or entity subject to the Employee Retirement Income Security Act of 1974, as amended, individual retirement account or individual retirement annuity, or give advice in a fiduciary capacity with respect to the materials presented herein. If you are an individual retirement or other investor, contact your financial advisor or other fiduciary unrelated to Quantopian about whether any given investment idea, strategy, product or service described herein may be appropriate for your circumstances. All investments involve risk, including loss of principal. Quantopian makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances.

Thanks Lee for the response. I could not find any other method that exist to use the divergence model.

In simple terms, Disagreement between the indicator and price is called divergence, and it can have significant implications for trade management. Divergence in an uptrend occurs when price makes a higher high, but the indicator does not make a higher high. In a downtrend, divergence occurs when price makes a lower low, but the indicator does not make a lower low. When divergence is spotted, there is a higher probability of a price retracement

Mode details on this link: http://www.investopedia.com/articles/trading/08/price-momentum.asp

Uvaraj,

Thanks for getting back to me! I put together a simple algorithm based off the information in the article. It tests for divergence when the MAVG hits a new 40 day high but the RSI doesn't and vice versa when the MAVG hits a new 40 day low. We can collaborate further on this if you were trying for something else.

-Seong

Thanks for sharing your work Seong. I cloned this algo and ran the backtest but it had no trades executed using both the daily and the minute data. Any ideas why?