This file contains hidden or 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 pandas as pd | |
from matplotlib import pyplot as plt | |
import os | |
# Class setup | |
class MovingAverage(): | |
def __init__(self, closing_prices): | |
self.data = pd.DataFrame(closing_prices) | |
def EMA(self, averaging_length=50): |
This file contains hidden or 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
buy = pd.DataFrame(index=closing_prices.index, columns=['Buy']) # an empty data-frame to store buy signals | |
sell = pd.DataFrame(index=closing_prices.index, columns=['Sell']) # an empty data-frame to store sell signals | |
for i in range(1, len(closing_prices)): # ignores first value of historical data as MACD will be equal to signal line there | |
if i == 1: | |
if MACD['EMA'].iloc[i] > signal_line['EMA'].iloc[i]: | |
high = 'MACD' | |
else: | |
high = 'SIGNAL' | |
elif MACD['EMA'].iloc[i] > signal_line['EMA'].iloc[i]: |
This file contains hidden or 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 pandas as pd | |
import os | |
# Class setup | |
class MovingAverage(): | |
def __init__(self, closing_prices): | |
self.data = pd.DataFrame(closing_prices) | |
def EMA(self, averaging_length=50): | |
ret = self.data.ewm( |