Skip to content

Instantly share code, notes, and snippets.

@yuyasugano
Created September 30, 2020 09:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yuyasugano/f8e815998daacf26756be722b54a318c to your computer and use it in GitHub Desktop.
Save yuyasugano/f8e815998daacf26756be722b54a318c to your computer and use it in GitHub Desktop.
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