Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
Need Python Algo Trading Strategy Code

Hi,

Please help me write my strategy in Python, I'm using Python 3.6.

Strategy

Stock Selection = Manually
Chart Setting = 15 mins Candlestick
Order Type = Cover Order
Stop Loss = As per ATR Trailing Stops

ATR Trailing Stops Value
Multiplier = 7
Period = 28

MACD values
Fast MA Period = 13
Slow MA Period = 30
Signal Period = 14

RSI Value
Period = 28
OverBought = 80
OverSold = 40

Buy when

  1. When MACD (13,30,14,Simple) is in Up Trend from past 30 days
  2. MACD (13,30,14,Simple) > MACD Signal MACD (13,30,14,Simple)
  3. MACD (13,30,14,Simple) > 0
  4. RSI > 80

Exit when
RSI < 80

Sell when

  1. when MACD (13,30,14,Simple) is in Down Trend from past 30 days
  2. MACD (13,30,14,Simple) < MACD Signal MACD (13,30,14,Simple)
  3. MACD (13,30,14,Simple) < 0
  4. RSI < 40

Exit when
RSI > 40

I've included everything in the strategy, Please write me an email if you need any other info.

Prashant
[email protected]

2 responses

Prashant - Welcome to Quantopian.

In general, you're unlikely to find someone who will code up a strategy for you. People are working on their own ideas, and the notion of "just doing it for someone" gets worn out by repeated requests similar to yours.

On the other hand, this community is great at helping people when they are working hard, and just need help to get unstuck. I suggest that you start coding your strategy yourself, and then look for help when you've gotten stuck.

  1. Do the getting started tutorial
  2. Do the pipeline tutorial
  3. Search the forums for previous work - like here and here

I hope that helps you on your way.

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.

Yeah man, please give this a try for yourself and then when you're STUCK, post your issues on Stack Overflow (like I did for months), then when your stuck on your working (almost) strategy, post the backtest/results on here and people will improve upon it if you're lucky : )

PS. Your RSI entries are backwards....