Trading Strategy - Technical Analysis With Python TA-Lib
Trading Strategy - Technical Analysis With Python TA-Lib
https://towardsdatascience.com/trading-strategy-technical-analysis-with-python-ta-lib-3ce9d6ce5614 1/7
3/4/2019 Trading Strategy: Technical Analysis with Python TA-Lib
— From Wikipedia
. . .
https://towardsdatascience.com/trading-strategy-technical-analysis-with-python-ta-lib-3ce9d6ce5614 2/7
3/4/2019 Trading Strategy: Technical Analysis with Python TA-Lib
start = '2015-04-22'
end = '2017-04-22'
symbol = 'MCD'
max_holding = 100
price = web.DataReader(name=symbol, data_source='quandl',
start=start, end=end)
price = price.iloc[::-1]
price = price.dropna()
close = price['AdjClose'].values
up, mid, low = BBANDS(close, timeperiod=20, nbdevup=2,
nbdevdn=2, matype=0)
rsi = RSI(close, timeperiod=14)
print("RSI (first 10 elements)\n", rsi[14:24])
Output
def bbp(price):
up, mid, low = BBANDS(close, timeperiod=20, nbdevup=2,
nbdevdn=2, matype=0)
bbp = (price['AdjClose'] - low) / (up - low)
return bbp
https://towardsdatascience.com/trading-strategy-technical-analysis-with-python-ta-lib-3ce9d6ce5614 3/7
3/4/2019 Trading Strategy: Technical Analysis with Python TA-Lib
holdings.ffill(inplace=True)
holdings.fillna(0, inplace=True)
holdings['Order'] = holdings.diff()
holdings.dropna(inplace=True)
fig.tight_layout()
plt.show()
https://towardsdatascience.com/trading-strategy-technical-analysis-with-python-ta-lib-3ce9d6ce5614 4/7
3/4/2019 Trading Strategy: Technical Analysis with Python TA-Lib
The below, I plot the action with green points (entry points) and red
points (exit points) with the Adjusted Close Price of the McDonald
(2015 April to 2017 April). Alongside, the RSI indicators and Bollinger
Bands are plotted to show how two indicators contribute to a trading
action. From the graph, it shows the strategy is good. It captures a
couple relative some low prices and high price during the period. One
should backtest to get how well the strategy does compared to
benchmark.
Result in graph
. . .
My other posts:
https://towardsdatascience.com/trading-strategy-technical-analysis-with-python-ta-lib-3ce9d6ce5614 5/7
3/4/2019 Trading Strategy: Technical Analysis with Python TA-Lib
https://towardsdatascience.com/trading-strategy-technical-analysis-with-python-ta-lib-3ce9d6ce5614 6/7
3/4/2019 Trading Strategy: Technical Analysis with Python TA-Lib
https://towardsdatascience.com/trading-strategy-technical-analysis-with-python-ta-lib-3ce9d6ce5614 7/7