Stock Indicators in Python

I have been fooling around with Python as a possible tool for technical analysis.  I coded a few of my favorite indicators.  The GitHub link is here.

  1. Bollinger Bands
  2. Keltner Channels
  3. RSI
  4. MACD
  5. ATR
  6. ADX
  7. Stochastics

I don’t think I am going to switch from C# and Multicharts, but Python is good for doing crazy stuff like the correlation indicator I wrote about last time (which, by the way, has been pegged below 50 all year – I’d love to know why).  Also, Bokeh shows great promise as a versatile charting program.

Indicators may look different from Stockcharts.com unless you attend to your scaling.  Stockcharts enforces a 0-100 for oscillators, Bokeh does not.

So, it’s another tool in the toolbox.  In fact, I noticed that most indicators are built with an iterative mindset that obviously reflects the programming languages of the day.  This is a great example of creativity being constrained by the tool set.

Ironically, the ones that are hard to do in a scalar language, like MACD, are easy in Python – and vice versa.  Wilder’s clever smoothing technique seems designed for a scalar language.  I used a little math and converted it to its equivalent EMA.

Coding lookback windows and rolling averages in Python feels like pounding a square peg into a round hole.  I suspect that the next wave of great indicators will be vector-based, reflecting modern ways of thinking about data.

Advertisements
This entry was posted in Indicators and tagged , , . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s