Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
MA Strategy - Simple

I am a totally beginner in Python. I am studying it now. Here's an algo I've just created(!) with Python for the first time and want to share with you guys. Please give me a lot of suggestions, recommendations and help. I am going to build more advanced and robust models from this simple strategy model. Please help. Thanks.

Strategy:

As you can see in the source code, this strategy is a very simple MA strategy. If price > MA (60) then buy, if price < MA(60) then sell. There's no risk managment and money management tool yet. #

For next step, I want to add here the following features.
1. Profit target ( '%' or 'number of tick' or '$')
2. Stop loss (same as #1)
3. ATR
4. Other variables: Fast Stochastic

Please hel me how to do this.

Thanks.

2 responses

Hey Kyu,

There are Quanoptian functions built in for stop orders and stop limit orders, but you will need to build in your own functionality for a stop loss.

There have been a few discussions on the forums regarding stop losses:
https://www.quantopian.com/posts/auto-adjusting-stop-loss
https://www.quantopian.com/posts/use-a-trailing-stop-loss

Here is a discussion that may be helpful for coding a profit taking strategy or profit target:
https://www.quantopian.com/posts/profit-taking

ATR and various stochastic oscillators are available as part of TA Lib:
http://qtstalker.sourceforge.net/talib.html

Ryan

Hi Ryan,

I had a little hard time to install TA-Lib, but somehow I did it.
Your info was very helpful and I'm still learning a lot.

Thanks a lot.