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

Hi, I am new here and have no programming knowledge. Please help! I want to build a very simple algo that does the following:

Intraday Minute by Minute Periods for Stoch an RSI
Stoch SlowK and SlowD - Interval 5 minutes (1 minute each), Slowing Period 3
RSI - 14 minute period

  1. If Stoch SlowD and SlowK is below 20 and Slow K > SlowD AND RSI is below 30 then Market Buy order for 100 shares of GOOG (as long as I don't have another open positions in GOOG currently --- If I do have open GOOG positions then don't execute another order)

  2. Once I have an open long GOOG position then I want it to Market sell 100 shares (Market Order) if GOOG increases by $10.....Or Market Sell 100 shares if GOOG decreases by $10.

  3. If X number of minutes have passed since I bought the stock and the price is $5 below my entry price then sell if Stoch SlowD and SlowK is above 80 and Slow K < SlowD AND RSI is above 70 then sell 100 shares of GOOG.

AND within the same algo I want the following running as well:

  1. If I don't have any current open position AND Stoch SlowD and SlowK is above 80 and Slow K < SlowD AND RSI is above 70 then Market Short order for 100 shares of GOOG.

  2. Once I have an open short GOOG position then I want it to Cover 100 shares (Market Order) once GOOG decreases by $10. Or Market Cover Order if GOOG increases by $10.

  3. If X number of minutes have passed since I shorted the stock and the price is $5 above my entry price then sell if Stoch SlowD and SlowK is below 20 and Slow K > SlowD AND RSI is below 30 then Cover 100 shares of GOOG.

Any help would be much appreciated.

John

4 responses

Hey John,

This sounds like a fun algo! I can take a stab at this, but I'm wondering if you'd like to learn python along the way too? We could collaborate on it and that way, it could be a lot more beneficial for you.

One more question! Could you explain what Stoch SlowK and SlowD are and how to calculate them?

-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.

SlowK and SlowD are the "normal" stochastic oscillator signals. This page provides an equation: http://stockcharts.com/school/doku.php?id=chart_school:technical_indicators:stochastic_oscillator

though when i implement that I get different values from what I see at other places like Yahoo finance, so....

Stochastic values within a few hundredths of TradingView, Google, others...

thanks for posting that Gary, I haven't used taLib so I should give that a try