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

Hello all,

First of all let me thank the Quantopian team for putting something so incredible together. I had been looking for a reason to get back into programming again and this seemed as good a reason as any to gain some experience with Python and the math involved in algorithmic trading.

So the algorithm in the post is my first crack at a trading strategy. I want to trade using a strategy combining the MACD and stochastic indicators. The MACD should be fairly straightforward to code so I have attempted to get the stochastic part working properly first. As you can see at the end of my code the problem is that the stochastic indicator data is not continuous. Defining an exact intersection point between the K and D indicators is difficult so I have used a 5% margin. Naturally this isn't ideal as the algorithm ends up buying and selling at not entirely correct times; sometimes sharp changes in the indicators means that opportunities to trade are skipped entirely.

So I suppose one way to fix this would be to perform some kind of interpolation to generate a well fitted curve on the K and D values as they are being calculated. I am new to python and not entirely aware of any packages that can do this. So any suggestions or other ideas would be greatly appreciated. Thank you!

2 responses

I am thinking that your algorithm will behave more like you are expecting it to if you switch to minute data so I went ahead and ported it over. I switched it to use talib instead of the built-in ta method because the ta methods are being depreciated. It looks better with the minute data.

David

Ah that's a good suggestion. Thank you!