1 Utilisez ce graphique Utilisez ce graphique import pandas as pd import pandas_datareader.data as web import ta import matplotlib.pyplot as plt from datetime import datetime # Fetch historical data def fetch_data(symbol, start, end): df = web.DataReader(symbol, 'yahoo', start, end) return df # Calculate indicators def apply_indicators(df): # Moving Averages df['SMA50'] = ta.trend.sma_indicator(df['Close'], window=50) df['SMA200'] = ta.trend.sma_indicator(df['Close'], window=200) # RSI df['RSI'] = ta.momentum.rsi(df['Close'], window=14) # MACD macd = ta.trend.MACD(df['Close']) df['MACD_diff'] = macd.macd_diff() return df # Identify entry points def identify_entries(df): conditions = [ (df['SMA50'] > df['SMA200']), # SMA50 above SMA200 (df['RSI'] > 50), # RSI above 50 (df['MACD_diff'] > 0) # MACD histogram positive ] df['Entry'] = (conditions[0] & conditions[1] & conditions[2]) return df # Plotting def plot_data(df): plt.figure(figsize=(14, 7)) plt.plot(df['Close'], label='Close Price') plt.plot(df['SMA50'], label='50-Day SMA') plt.plot(df['SMA200'], label='200-Day SMA') # Highlight entry points entries = df[df['Entry']] plt.scatter(entries.index, entries['Close'], color='g', label='Entry Point', marker='^', s=100) plt.title('XAUUSD Entry Points') plt.legend() plt.show() # Main function def main(): symbol = 'XAUUSD=X' start = datetime(2020, 1, 1) end = datetime.now() df = fetch_data(symbol, start, end) df = apply_indicators(df) df = identify_entries(df) plot_data(df) return df # Run the script df = main()
Clause de non-responsabilité 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 .