Search
Products
Community
Markets
News
Brokers
More
EN
Get started
Community
/
Ideas
/
Meshal
CFDs on Gold (US$ / OZ)
Meshal
By meshaltrading
Follow
Follow
Apr 24, 2023
1
Apr 24, 2023
```
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()
```
Chart Patterns
meshaltrading
Follow
Related publications
50
by meshaltrading
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
.