Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
A support and resistence line sample
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