I have a .csv file with columns "Date", "High", "Low", "Open", "Close" data from a stock.
df_closes could be used as closing prices for further processing.
Now i want to scan the pandas dataframe df_closes for a TD Sequential 9 buy or sell setup.
I want to scan if there is a 9 count in the current daily candle or not.
The TD system works like regarding this pictures.
You always compare the current closing price to the closing price 4 bars earlier.
It´s well explained in picture1 at section 4>
TD9 buy: https://tradetrekker.files.wordpress.com/2012/09/screen-shot-2013-04-07-at-8-39-04-pm.png
TD9 sell: https://tradetrekker.files.wordpress.com/2012/09/screen-shot-2013-04-07-at-8-48-37-pm.png
I also found a great python script where the TD indicator is already implemented. https://github.com/mk99999/TD-seq/blob/master/TD_seq_calc.py
But as i´m new to python i need some help to get my pandas dataframe into this Indicator.
Maybe i could use some parts of TD_seq_calc.py in my script?
Thanks!
from datetime import datetime, timedelta
import pandas as pd
import yfinance as yf
import os
from pandas_datareader import data as pdr
yf.pdr_override()
if not os.path.exists('stock_data/daily'):
os.makedirs('stock_data/daily')
#write stock data to csv file
ticker = "NSC"
start = datetime.today() - timedelta(days=70)
data = pdr.get_data_yahoo(ticker, start=start, interval = "1d")
data.to_csv('stock_data/daily/{}.csv'.format(ticker))
#read stock data from csv file
df = pd.read_csv('stock_data/daily/{}.csv'.format(ticker), parse_dates=True, index_col=0)
df_closes = df['Close']
print(df_closes)
#now scan for a TD9 buy or sell setup of the current daily closing price
# The ticker 'NSC' has a TD9 buy today (14.8.2019)
Aucun commentaire:
Enregistrer un commentaire