Build Technical Indicators in Python - Matlab, R project and Python | futures io social day trading

Build Technical Indicators in Python
 Updated: July 8th, 2016 (09:18 AM) Views / Replies: 1,652 / 2 Created: June 16th, 2016 (07:12 AM) by algoisgame Attachments: 0

 Welcome to futures io.

# Build Technical Indicators in Python

mumbai india

Futures Experience: None
Favorite Futures: currency futures

Posts: 1 since Jun 2016

Build Technical Indicators in Python

Technical Indicator is essentially a mathematical representation based on data sets such as price (high, low, open, close, etc.) or volume of a security to forecast price trends. There are several kinds of technical indicators that are used to analyse and detect the direction of movement of the price. Traders use them to study the short-term price movement, since they do not prove very useful for long-term investors. They are employed to primarily to predict the future price levels.

Technical Indicators do not follow a general pattern, meaning, they behave differently with every security. What can be a good indicator for a particular security, might not hold the case for the other. Thus, using a technical indicator requires jurisprudence coupled with good experience.

In the following post, I will highlight a technical indicators that are popularly used in the markets to study the price movement.

CCI

As these analyses can be done in python, a snippet of code is also inserted along with the description of the indicators. Sample charts with examples are also appended for clarity.

Commodity Channel Index (CCI)

The commodity channel index (CCI) is an oscillator which was originally introduced by Donald Lambert in 1980. CCI can be used to identify cyclical turns across asset classes, be it commodities, indices, stocks, or ETFs. CCI is also used by traders to identify overbought/oversold levels for securities.

Estimation

The CCI looks at the relationship between price and a moving average. Steps involved in the estimation of CCI include:

Computing the typical price for the security. Typical price is obtained by the averaging the high, low and the close price for the day.
Finding the moving average for the chosen number of days based on the typical price.
Computing the standard deviation for the same period as that used for the MA.
The formula for CCI is given by:

Code
 ```CCI = (Typical price – MA of Typical price) / (0.015 * Standard deviation of Typical price) The index is scaled by an inverse factor of 0.015 to provide for more readable numbers.```
The index is scaled by an inverse factor of 0.015 to provide for more readable numbers.

Analysis

CCI can be used to determine overbought and oversold levels. Readings above +100 can imply an overbought condition, while readings below −100 can imply an oversold condition. However, one should be a careful because a security can continue moving higher after the CCI indicator becomes overbought. Likewise, securities can continue moving lower after the indicator becomes oversold.

Whenever the security is in overbought/oversold levels as indicated by the CCI, there is a good chance that the price will see corrections. Hence a trader can use such overbought/oversold levels to enter in short/long positions.

Traders can also look for divergence signals to take suitable positions using CCI. A bullish divergence occurs when the underlying security makes a lower low and the CCI forms a higher low, which shows less downside momentum. Similarly, a bearish divergence is formed when the security records a higher high and the CCI forms a lower high, which shows less upside momentum.

Python code for computing the Commodity Channel Index

In the code below we use the Series, rolling_mean, rolling_std, and the join functions to compute the Commodity Channel Index. The Series function is used to form a series which is a one dimensional array-like object containing an array of data. The rolling_mean function takes a time series or a data frame along with the number of periods and computes the mean. The rolling_std function computes the standard deviation based on the price provided. The join function joins a given series with a specified series/dataframe.

Code
 ```# Commodity Channel Index Python Code # Load the necessary packages and modules import pandas as pd import pandas.io.data as web import matplotlib.pyplot as plt # Commodity Channel Index def CCI(data, ndays): TP = (data['High'] + data['Low'] + data['Close']) / 3 CCI = pd.Series((TP - pd.rolling_mean(TP, ndays)) / (0.015 * pd.rolling_std(TP, ndays)), name = 'CCI') data = data.join(CCI) return data # Retrieve the Nifty data from Yahoo finance: data = web.DataReader('^NSEI',data_source='yahoo',start='1/1/2014', end='1/1/2016') data = pd.DataFrame(data) # Compute the Commodity Channel Index(CCI) for NIFTY based on the 20-day Moving average n = 20 NIFTY_CCI = CCI(data, n) CCI = NIFTY_CCI['CCI'] # Plotting the Price Series chart and the Commodity Channel index below fig = plt.figure(figsize=(7,5)) ax = fig.add_subplot(2, 1, 1) ax.set_xticklabels([]) plt.plot(data['Close'],lw=1) plt.title('NSE Price Chart') plt.ylabel('Close Price') plt.grid(True) bx = fig.add_subplot(2, 1, 2) plt.plot(CCI,'k',lw=0.75,linestyle='-',label='CCI') plt.legend(loc=2,prop={'size':9.5}) plt.ylabel('CCI values') plt.grid(True) plt.setp(plt.gca().get_xticklabels(), rotation=30)```

 The following 2 users say Thank You to algoisgame for this post:

 June 16th, 2016, 07:12 AM #2 (permalink) Quick Summary Quick Summary Post Quick Summary is created and edited by users like you... Add FAQ's, Links and other Relevant Information by clicking the edit button in the lower right hand corner of this message.

 July 8th, 2016, 09:18 AM #3 (permalink) Trading Apprentice Cookeville, TN   Futures Experience: Advanced Platform: R|Trader, Thinkorswim Favorite Futures: CL, RB, 6E, ZB, DX   Posts: 44 since Oct 2011 Thanks: 10 given, 15 received Quantiacs had a good post today about constructing Heiken-Ashi candles in Python, using the numpy library, see here: https://quantiacs.com/Blog/Intro-to-Algorithmic-Trading-with-Heikin-Ashi.aspx

 futures io > Build Technical Indicators in Python

Upcoming Webinars and Events (4:30PM ET unless noted)

Elite only

## Digging into the Details of iSystems w/Stage 5 & iSystems

Jun 5

 Similar Threads Thread Thread Starter Forum Replies Last Post Branzol Matlab, R project and Python 39 September 12th, 2017 07:48 AM jamesico Matlab, R project and Python 2 September 9th, 2014 07:19 AM Keith Leesus Matlab, R project and Python 2 September 5th, 2014 12:23 AM wlblount Hire a Consultant or Programmer 0 December 25th, 2013 09:14 AM sigjanu Platforms and Indicators 1 March 17th, 2011 11:53 AM

All times are GMT -4. The time now is 09:50 PM.

 Copyright © 2018 by futures io, s.a., Av Ricardo J. Alfaro, Century Tower, Panama, +507 833-9432, info@futures.io All information is for educational use only and is not investment advice.There is a substantial risk of loss in trading commodity futures, stocks, options and foreign exchange products. Past performance is not indicative of future results.
no new posts
Page generated 2018-05-27 in 0.08 seconds with 19 queries on phoenix via your IP 54.81.183.183