0 احصل على هذا الرسم احصل على هذا الرسم 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.
إخلاء المسؤولية لا يُقصد بالمعلومات والمنشورات أن تكون، أو تشكل، أي نصيحة مالية أو استثمارية أو تجارية أو أنواع أخرى من النصائح أو التوصيات المقدمة أو المعتمدة من TradingView. اقرأ المزيد في
شروط الاستخدام .