Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
Multiple Indicators Combined

I'm trying to improve this algorithm that uses two different crossing moving averages and the rsi as signals and combines them into one:

  • How can I reduce the max drawdown? I tried using the stop loss but it does not seem to work. Maybe the algorithm does many unsuccessfull trades.
  • How do I let the algorithm select the stocks? Right now they are hand picked and this suffers from both survivorship bias and selection bias.
  • Could an ai optimize the weight of the different signals? Now they are all equal to one...
  • I tried using the MACD signal too but got worst results so I removed it. It take a lot of code for something so common. Is there a better way to iterate on signals?

What are your thoughts?

Thanks

9 responses

Im no expert and quite a beginner but I believe that you can generate the stocks to be picked in the before_trading_start part of the source code and then use an SQL query to sift through them and then update_universe based on the parameters you set. Hope this somewhat helped.

https://www.quantopian.com/help#api-order

You will need a screener to select your candidate stocks. Your screening can be based on trading volumes, valuation ....whatever. It will make your life easy. Once you have screened the stocks, one way to reduce max drawdown is to have a set of performing strategies but with uncorrelated drawdowns. You can let a neural net or any regressor find the weights by itself. But be sure to check the output of your ai algorithm on unseen (out of sample). Hope this helps. Wish you luck.

Great Work, im trying to use this strategy LIVE by hand on an BULL OMX30 X18 derivate for the stockholm OMX30 index.. damn hard the analog way.

I think what you are trying to do is to risk-manage your strategy. Many strategies work alright on average, but using a little overlay of risk management will go a long way in improving your returns and reducing your drawdowns (volatility).

One way to reduce your drawn downs is to use optimization, instead of hard-coding your stop-loss or using moving averages as indicators, why not target a volatility, and scale your strategy weights in conjunction with your target volatility?

A good example will be this (http://papers.ssrn.com/sol3/papers.cfm?abstract_id=2371227)

The authors found that using a dynamic weighted momentum strategy by optimizing the returns using a target volatility of 12% doubles the sharpe ratio of a traditional dual momentum strategy.

I've tried this cloned algo with a few different RSI and MA criteria but it doesent want to sell the shares once it reaches the point where the Combo becomes negative (it just holds them). Is there something that needs to be added to the close section once combo score becomes negative?

The backtest does show it sells shares.
Thanks guys for the suggestions on stock picking and volatility. I might work on it more this week.

I'm a new user, please forgive me if I understand your question incorrectly... I don't know why you only pick a few stocks as below
MMM', 'GOOG_L', 'PG', 'DIA', 'AAPL', 'TSLA', 'NFLX', 'SPY' which might be a reason to get high max drawdown. Since, GOOG, TSLA, AAPL are volatile stocks. Can you have a dynamic list of stocks based on ATR and price ratios?
Does Quantopian support dynamic list of stock?

Isn't this a bug?

order_target_percent(stock, context.pct_per_stock, style=StopLimitOrder(price*context.STOP_LOSS, price*context.STOP_LOSS))  

Should probably be:
order_target_percent(stock, 0, style=StopLimitOrder(price*context.STOP_LOSS, price*context.STOP_LOSS))

(Or your leverage will explode)

@Weimin, yes you can create a dynamic stock list using the set_universe() function or fundamental data. There's more info (and examples) in the API documentation.

We're working right now to allow you to create dynamic universes using any custom criteria (like indicators and price ratios). The high level details were laid out in this thread. Check it out!

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.