```
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
data = pd.read_csv("gold_price.csv")
data["MA50"] = data["Price"].rolling(window=50).mean()
data["Buy"] = np.where(data["Price"] > data["MA50"], 1, 0)
data["Sell"] = np.where(data["Price"] < data["MA50"], 1, 0)
plt.figure(figsize=(12,6))
plt.plot(data["Price"], label="Price")
plt.plot(data["MA50"], label="MA50")
plt.plot(data.loc[data["Buy"] == 1, "Price"], "go", label="Buy")
plt.plot(data.loc[data["Sell"] == 1, "Price"], "ro", label="Sell")
plt.legend(loc="upper left")
plt.show()
```
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
data = pd.read_csv("gold_price.csv")
data["MA50"] = data["Price"].rolling(window=50).mean()
data["Buy"] = np.where(data["Price"] > data["MA50"], 1, 0)
data["Sell"] = np.where(data["Price"] < data["MA50"], 1, 0)
plt.figure(figsize=(12,6))
plt.plot(data["Price"], label="Price")
plt.plot(data["MA50"], label="MA50")
plt.plot(data.loc[data["Buy"] == 1, "Price"], "go", label="Buy")
plt.plot(data.loc[data["Sell"] == 1, "Price"], "ro", label="Sell")
plt.legend(loc="upper left")
plt.show()
```
Disclaimer
The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.
Disclaimer
The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.