-
-
Save quantra-go-algo/b3cb57de93803561e544d8240f7d3552 to your computer and use it in GitHub Desktop.
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
# Plotting the strategy signals | |
plt.figure(figsize=(12, 6)) | |
plt.plot(aapl_data['Close'], label='AAPL Close Price', alpha=0.5) | |
plt.plot(aapl_data['SMA_50'], label='50-day SMA') | |
plt.plot(aapl_data['SMA_200'], label='200-day SMA') | |
plt.plot(aapl_data.loc[aapl_data['Signal'] == 1, 'Close'], '^', markersize=3, color='g', label='Buy Signal') | |
plt.plot(aapl_data.loc[aapl_data['Signal'] == -1, 'Close'], 'v', markersize=3, color='r', label='Sell Signal') | |
plt.title('AAPL Stock Price with Moving Average Strategy Signals') | |
plt.xlabel('Date') | |
plt.ylabel('Stock Price') | |
plt.legend() | |
plt.show() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment