1 Utilisez ce graphique Utilisez ce graphique 1 1 import numpy as np import pandas as pd import matplotlib.pyplot as plt # Define the technical indicators. def macd(close, fast_period=12, slow_period=26, signal_period=9): """ Calculate the MACD. Args: close (pandas.Series): The closing prices. fast_period (int): The fast period. slow_period (int): The slow period. signal_period (int): The signal period. Returns: pandas.Series: The MACD. """ ema_fast = close.ewm(span=fast_period, adjust=False).mean() ema_slow = close.ewm(span=slow_period, adjust=False).mean() macd = ema_fast - ema_slow signal = macd.ewm(span=signal_period, adjust=False).mean() return macd, signal def rsi(close, period=14): """ Calculate the RSI. Args: close (pandas.Series): The closing prices. period (int): The period. Returns: pandas.Series: The RSI. """ delta = close.diff() up = delta.clip(lower=0) down = -delta.clip(upper=0) ema_up = up.ewm(span=period, adjust=False).mean() ema_down = down.ewm(span=period, adjust=False).mean() rsi = 100 * ema_up / (ema_up + ema_down) return rsi def bollinger_bands(close, period=20, stddev=2): """ Calculate the Bollinger bands. Args: close (pandas.Series): The closing prices.
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 .