A support and resistence line sample
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
import pandas as pd | |
import matplotlib.pyplot as plt | |
def supres_plot(df, support, resistence): | |
for i in range(len(support)): | |
print('Support line {0} is {1}'.format(i, support[i])) | |
for i in range(len(resistence)): | |
print('Resistence line {0} is {1}'.format(i, resistence[i])) | |
fig, ax1 = plt.subplots(figsize=(15,10)) | |
color = 'tab:green' | |
xdate = [x.date() for x in df.index] | |
ax1.plot(xdate, df['Close'], label='close', color=color) | |
ax1.plot(xdate, df['High'], label='high') | |
ax1.plot(xdate, df['Low'], label='low') | |
for sup in support: | |
ax1.axhline(y=sup, linewidth='1.0', color='red') | |
for res in resistence: | |
ax1.axhline(y=res, linewidth='1.0', color='blue') | |
ax1.legend() | |
ax1.set_title(label='Support and resistence lines') | |
plt.grid() | |
plt.show() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment