Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
Trading on multiple TA-Lib signals

One thing that many traders do is look at multiple signals in conjunction with one another. If all the signals indicate the same thing, they are often more likely to be correct.

Here's an example using three signals generated from TA-Lib. I want this post to serve a couple purposes — introducing the strategy and showing how to use the talib module.

This strategy takes a chunk of stocks, and for each stock, it looks at three signals. If all the signals for a stock are in agreement about whether it is overbought or underbought, then we go short or long. The three signals we use are:

  • Money flow index
  • Commodity channel index
  • Chande momentum oscillator

You can see the thresholds I use and other variables, like time period and the universe size, in the source code. Since the "ta." notation is being deprecated, using functions from the talib module is better.

Interestingly enough, the strategy does very well from about 2002 - 2009. After that, it mostly trends around the benchmark. I wonder if there is a good reason why it did so well for a while then slowed down (the backtest below is run from 2004 - 2006). Feel free to clone the algorithm and adjust it. Also try using other functions from TA-Lib as signals, specifically have a look at the various oscillators.

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.

3 responses

Here's another example. This one only trades one stock, the SPY, and records the indicators. It is also designed for minute mode and live trading, and because of that uses the history functions instead of deques to retrieve past data.

And here's one more using more signals and slightly different logic.

Hi. Will anyone be able to re-code this for the new API?