import pandas as pd import matplotlib.pyplot as plt
# Load data # For this example, we'll use a CSV file with 'Date' and 'Close' columns. # Adjust the file path as needed. data = pd.read_csv('path/to/your/data.csv')
# Convert 'Date' column to datetime data['Date'] = pd.to_datetime(data['Date'])
# Set 'Date' column as the index data.set_index('Date', inplace=True)
# Define the short-term and long-term moving averages short_window = 50 long_window = 200
# Calculate the short-term and long-term moving averages data['Short_MA'] = data['Close'].rolling(window=short_window, min_periods=1).mean() data['Long_MA'] = data['Close'].rolling(window=long_window, min_periods=1).mean()
Les informations et les publications ne sont pas destinées à être, et ne constituent pas, des conseils ou des recommandations en matière de finance, d'investissement, de trading ou d'autres types de conseils fournis ou approuvés par TradingView. Pour en savoir plus, consultez les Conditions d'utilisation.