-
-
Save quantra-go-algo/df394a7812220a8153eda95d0e6bf3e7 to your computer and use it in GitHub Desktop.
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
| # Function to plot the strategy results | |
| def plot_strategy(data): | |
| plt.figure(figsize=(12, 6)) | |
| plt.plot(data['Close'], label='Close Price', alpha=0.5) | |
| plt.scatter(data[data['Signal'] == 1].index, data['Close'][data['Signal'] == 1], marker='^', color='g', label='Buy Signal') | |
| plt.scatter(data[data['Signal'] == -1].index, data['Close'][data['Signal'] == -1], marker='v', color='r', label='Sell Signal') | |
| plt.plot(data['SAR'], label='Parabolic SAR', linestyle='dashed', alpha=0.5) | |
| plt.title('Parabolic SAR Trading Strategy') | |
| plt.xlabel('Date') | |
| plt.ylabel('Price') | |
| plt.legend() | |
| plt.show() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment