| | import streamlit as st |
| | import pandas as pd |
| | import numpy as np |
| | import yfinance as yf |
| | import plotly.graph_objects as go |
| | from plotly.subplots import make_subplots |
| | import warnings |
| | warnings.filterwarnings('ignore') |
| | from curl_cffi import requests |
| | session = requests.Session(impersonate="chrome") |
| |
|
| | |
| | from technical_indicators import * |
| |
|
| | |
| | st.set_page_config( |
| | page_title="Technical Analysis Dashboard", |
| | page_icon="π", |
| | layout="wide", |
| | initial_sidebar_state="expanded" |
| | ) |
| |
|
| | |
| | st.markdown(""" |
| | <style> |
| | .main-header { |
| | font-size: 2.5rem; |
| | font-weight: bold; |
| | color: #1f77b4; |
| | text-align: center; |
| | margin-bottom: 2rem; |
| | } |
| | .sub-header { |
| | font-size: 1.5rem; |
| | font-weight: bold; |
| | text-align: center; |
| | margin-bottom: 1rem; |
| | } |
| | .metric-container { |
| | background-color: #f0f2f6; |
| | padding: 1rem; |
| | border-radius: 0.5rem; |
| | margin: 0.5rem 0; |
| | } |
| | .indicator-section { |
| | background-color: #ffffff; |
| | padding: 1.5rem; |
| | border-radius: 0.5rem; |
| | margin: 1rem 0; |
| | border: 1px solid #e0e0e0; |
| | } |
| | </style> |
| | """, unsafe_allow_html=True) |
| |
|
| | |
| | st.markdown('<h1 class="main-header">π Technical Analysis Dashboard</h1>', unsafe_allow_html=True) |
| | st.markdown('<h3 class="sub-header">Developed By Zane Vijay Falcao</h3>', unsafe_allow_html=True) |
| | st.divider() |
| | |
| | with st.sidebar: |
| | st.header("π Configuration") |
| | |
| | |
| | symbol = st.text_input("Stock Symbol", value="AAPL", help="Enter stock symbol (e.g., AAPL, GOOGL, MSFT)") |
| | |
| | |
| | period = st.selectbox( |
| | "Time Period", |
| | ["1mo", "3mo", "6mo", "1y", "2y", "5y", "max"], |
| | index=3 |
| | ) |
| | |
| | |
| | interval = st.selectbox( |
| | "Data Interval", |
| | ["1d", "5d", "1wk", "1mo"], |
| | index=0 |
| | ) |
| | |
| | st.divider() |
| | |
| | |
| | st.header("π Select Indicators") |
| | |
| | |
| | with st.expander("Trend Indicators", expanded=True): |
| | show_sma = st.checkbox("Simple Moving Average (SMA)", value=True) |
| | show_ema = st.checkbox("Exponential Moving Average (EMA)", value=True) |
| | show_hma = st.checkbox("Hull Moving Average (HMA)") |
| | show_wma = st.checkbox("Weighted Moving Average (WMA)") |
| | show_kama = st.checkbox("Kaufman Adaptive Moving Average (KAMA)") |
| | show_frama = st.checkbox("Fractal Adaptive Moving Average (FRAMA)") |
| | show_evwma = st.checkbox("Ehlers Volatility Weighted MA (EVWMA)") |
| | show_vwap = st.checkbox("Volume Weighted Average Price (VWAP)") |
| | show_dema = st.checkbox("Double Exponential Moving Average (reduces lag compared to EMA) (DEMA)", key="dema_trend") |
| | show_zlema = st.checkbox("Zero Lag Exponential Moving Average (ZLEMA)", key="zlema_trend") |
| | show_smm = st.checkbox("Simple Moving Median (SMM)") |
| | show_ssma = st.checkbox("Smoothed SMA (SSMA)") |
| | show_tema = st.checkbox("Triple Exponential Moving Average (TEMA)", key="tema_trend") |
| | show_trima = st.checkbox("Triangular Moving Average (TRIMA)") |
| |
|
| |
|
| | |
| | with st.expander("Momentum Indicators", expanded=True): |
| | show_rsi = st.checkbox("Relative Strength Index (RSI)", value=True) |
| | show_macd = st.checkbox("MACD", value=True) |
| | show_stochrsi = st.checkbox("Stochastic RSI") |
| | show_cmo = st.checkbox("Chande Momentum Oscillator (CMO)") |
| | show_roc = st.checkbox("Rate of Change (ROC)") |
| | show_tsi = st.checkbox("True Strength Index (TSI)") |
| | show_kst = st.checkbox("Know Sure Thing (KST)") |
| | show_ppo = st.checkbox("Price Percentage Oscillator (PPO)") |
| | show_uo = st.checkbox("Ultimate Oscillator (UO)") |
| | show_mom = st.checkbox("Momentum (MOM)") |
| | show_dymi = st.checkbox("Dynamic Momentum Index (DYMI)") |
| | show_trix = st.checkbox("Triple Exponential Average (TRIX)", key="trix_momentum") |
| |
|
| | |
| | |
| | with st.expander("Volume Indicators"): |
| | show_obv = st.checkbox("On-Balance Volume (OBV)") |
| | show_adl = st.checkbox("Accumulation/Distribution Line (ADL)") |
| | show_chaikin = st.checkbox("Chaikin Oscillator") |
| | show_efi = st.checkbox("Elder's Force Index (EFI)") |
| | show_emv = st.checkbox("Ease of Movement (EMV)") |
| | show_mfi = st.checkbox("Money Flow Index (MFI)") |
| | show_vpt = st.checkbox("Volume Price Trend (VPT)") |
| | show_fve = st.checkbox("Fractal Volume Efficiency (FVE)") |
| | show_vzo = st.checkbox("Volume Zone Oscillator (VZO)") |
| | show_wobv = st.checkbox("Weighted On-Balance Volume (WOBV)") |
| | |
| | |
| | with st.expander("Volatility Indicators"): |
| | show_bollinger = st.checkbox("Bollinger Bands", value=True) |
| | show_kc = st.checkbox("Keltner Channels") |
| | show_dc = st.checkbox("Donchian Channels") |
| | show_atr = st.checkbox("Average True Range (ATR)") |
| | show_chandelier = st.checkbox("Chandelier Exit") |
| | show_psar = st.checkbox("Parabolic SAR") |
| | show_apz = st.checkbox("Adaptive Price Zone (APZ)") |
| | |
| | |
| | with st.expander("Oscillators"): |
| | show_adx = st.checkbox("Average Directional Index (ADX)") |
| | show_cci = st.checkbox("Commodity Channel Index (CCI)") |
| | show_fish = st.checkbox("Fisher Transform") |
| | show_ao = st.checkbox("Awesome Oscillator (AO)") |
| | show_mi = st.checkbox("Mass Index (MI)") |
| | show_wto = st.checkbox("Wave Trend Oscillator (WTO)") |
| | show_copp = st.checkbox("Coppock Curve") |
| | show_ift_rsi = st.checkbox("Inverse Fisher Transform RSI") |
| | show_qstick = st.checkbox("Q Stick") |
| | show_vbm = st.checkbox("Volatility-Based Momentum (VBM)") |
| |
|
| | |
| | |
| | with st.expander("Complex Indicators"): |
| | show_ichimoku = st.checkbox("Ichimoku Cloud") |
| | show_pivot = st.checkbox("Pivot Points") |
| | show_pivot_fib = st.checkbox("Fibonacci Pivot Points") |
| | show_basp = st.checkbox("Buyer and Seller Pressure (BASP)") |
| | show_baspn = st.checkbox("Normalized BASP") |
| | show_dmi = st.checkbox("Directional Movement Index (DMI)") |
| | show_ebbp = st.checkbox("Elder Bull/Bear Power") |
| | show_ebbp_v = st.checkbox("Elder Bull/Bear Power Volume", key="ebbp_volume") |
| | show_sar = st.checkbox("Stop and Reverse (SAR)") |
| | show_cfi = st.checkbox("Cumulative Force Index (CFI)") |
| |
|
| | |
| | st.divider() |
| | |
| | |
| | st.header("βοΈ Parameters") |
| | sma_period = st.slider("SMA Period", 5, 50, 20) |
| | ema_period = st.slider("EMA Period", 5, 50, 20) |
| | rsi_period = st.slider("RSI Period", 5, 30, 14) |
| | bb_period = st.slider("Bollinger Bands Period", 10, 30, 20) |
| | bb_std = st.slider("Bollinger Bands Std Dev", 1.0, 3.0, 2.0, 0.1) |
| |
|
| |
|
| | col1, col2, col3, col4, col5 = st.columns(5) |
| | st.divider() |
| | @st.cache_data |
| | def fetch_data(symbol, period, interval): |
| | ticker = yf.Ticker(symbol.upper(), session=session) |
| | return ticker.history(period=period, interval=interval) |
| |
|
| | |
| | if col3.button("π Analyze Stock", type="secondary", use_container_width=True): |
| | |
| | try: |
| | |
| | with st.spinner(f"Fetching data for {symbol.upper()}..."): |
| | |
| | data = fetch_data(symbol, period, interval) |
| | |
| | if data.empty: |
| | st.error("No data found for the given symbol. Please check the symbol and try again.") |
| | st.stop() |
| | |
| | |
| | col1, col2, col3, col4 = st.columns(4) |
| | |
| | with col1: |
| | st.metric("Current Price", f"${data['Close'].iloc[-1]:.2f}") |
| | |
| | with col2: |
| | price_change = data['Close'].iloc[-1] - data['Close'].iloc[-2] |
| | st.metric("Price Change", f"${price_change:.2f}", f"{price_change:.2f}") |
| | |
| | with col3: |
| | pct_change = (price_change / data['Close'].iloc[-2]) * 100 |
| | st.metric("% Change", f"{pct_change:.2f}%", f"{pct_change:.2f}%") |
| | |
| | with col4: |
| | st.metric("Volume", f"{data['Volume'].iloc[-1]:,.0f}") |
| | |
| | |
| | indicators = {} |
| | |
| | |
| | if show_sma: |
| | indicators['SMA'] = SMA(data, sma_period) |
| | if show_ema: |
| | indicators['EMA'] = EMA(data, ema_period) |
| | if show_hma: |
| | indicators['HMA'] = HMA(data, 20) |
| | if show_wma: |
| | indicators['WMA'] = WMA(data, 20) |
| | if show_kama: |
| | indicators['KAMA'] = KAMA(data) |
| | if show_frama: |
| | indicators['FRAMA'] = FRAMA(data) |
| | if show_evwma: |
| | indicators['EVWMA'] = EVWMA(data) |
| | if show_vwap: |
| | indicators['VWAP'] = VWAP(data) |
| | if show_dema: |
| | indicators['DEMA'] = DEMA(data, ema_period) |
| | if show_zlema: |
| | indicators['ZLEMA'] = ZLEMA(data, ema_period) |
| | if show_smm: |
| | indicators['SMM'] = SMM(data) |
| | if show_ssma: |
| | indicators['SSMA'] = SSMA(data) |
| | if show_tema: |
| | indicators['TEMA'] = TEMA(data, ema_period) |
| | if show_trima: |
| | indicators['TRIMA'] = TRIMA(data, ema_period) |
| |
|
| | |
| | if show_rsi: |
| | indicators['RSI'] = RSI(data, rsi_period) |
| | if show_macd: |
| | indicators['MACD'] = MACD(data) |
| | if show_stochrsi: |
| | indicators['StochRSI'] = STOCHRSI(data) |
| | if show_cmo: |
| | indicators['CMO'] = CMO(data) |
| | if show_roc: |
| | indicators['ROC'] = ROC(data) |
| | if show_tsi: |
| | indicators['TSI'] = TSI(data) |
| | if show_kst: |
| | indicators['KST'] = KST(data) |
| | if show_ppo: |
| | indicators['PPO'] = PPO(data) |
| | if show_uo: |
| | indicators['UO'] = UO(data) |
| | if show_mom: |
| | indicators['MOM'] = MOM(data) |
| | if show_dymi: |
| | indicators['DYMI'] = DYMI(data) |
| | if show_trix: |
| | indicators['TRIX'] = TRIX(data, ema_period) |
| | |
| | |
| | if show_obv: |
| | indicators['OBV'] = OBV(data) |
| | if show_adl: |
| | indicators['ADL'] = ADL(data) |
| | if show_chaikin: |
| | indicators['Chaikin'] = CHAIKIN(data) |
| | if show_efi: |
| | indicators['EFI'] = EFI(data) |
| | if show_emv: |
| | indicators['EMV'] = EMV(data) |
| | if show_mfi: |
| | indicators['MFI'] = MFI(data) |
| | if show_vpt: |
| | indicators['VPT'] = VPT(data) |
| | if show_fve: |
| | indicators['FVE'] = FVE(data) |
| | if show_vzo: |
| | indicators['VZO'] = VZO(data) |
| | if show_wobv: |
| | indicators['WOBV'] = WOBV(data) |
| | if show_vpt: |
| | indicators['VPT'] = VPT(data) |
| | |
| | |
| | if show_bollinger: |
| | indicators['Bollinger'] = BOLLINGER(data, bb_period, bb_std) |
| | if show_kc: |
| | indicators['KC'] = KC(data) |
| | if show_dc: |
| | indicators['DC'] = DC(data) |
| | if show_atr: |
| | indicators['ATR'] = ATR(data) |
| | if show_chandelier: |
| | indicators['Chandelier'] = CHANDELIER(data) |
| | if show_psar: |
| | indicators['PSAR'] = PSAR(data) |
| | if show_apz: |
| | indicators['APZ'] = APZ(data) |
| | |
| | |
| | if show_adx: |
| | indicators['ADX'] = ADX(data) |
| | if show_cci: |
| | indicators['CCI'] = CCI(data) |
| | if show_fish: |
| | indicators['Fisher'] = FISH(data) |
| | if show_ao: |
| | indicators['AO'] = AO(data) |
| | if show_mi: |
| | indicators['MI'] = MI(data) |
| | if show_wto: |
| | indicators['WTO'] = WTO(data) |
| | if show_copp: |
| | indicators['Coppock'] = COPP(data) |
| | if show_ift_rsi: |
| | indicators['IFT_RSI'] = IFT_RSI(data) |
| | if show_qstick: |
| | indicators['QSTICK'] = QSTICK(data) |
| | if show_vbm: |
| | indicators['VBM'] = VBM(data) |
| | |
| | |
| | if show_ichimoku: |
| | indicators['Ichimoku'] = ICHIMOKU(data) |
| | if show_pivot: |
| | indicators['Pivot'] = PIVOT(data) |
| | if show_pivot_fib: |
| | indicators['Pivot_Fib'] = PIVOT_FIB(data) |
| | if show_basp: |
| | indicators['BASP'] = BASP(data) |
| | if show_baspn: |
| | indicators['BASPN'] = BASPN(data) |
| | if show_dmi: |
| | indicators['DMI'] = DMI(data) |
| | if show_ebbp: |
| | indicators['EBBP'] = EBBP(data) |
| | if show_sar: |
| | indicators['SAR'] = SAR(data) |
| | if show_cfi: |
| | indicators['CFI'] = CFI(data) |
| |
|
| | |
| | |
| | fig = make_subplots( |
| | rows=4, cols=1, |
| | shared_xaxes=True, |
| | vertical_spacing=0.05, |
| | subplot_titles=( |
| | 'Price & Moving Averages / Bands', |
| | 'Volume-Based Indicators', |
| | 'Momentum Oscillators', |
| | 'Trend / Volatility / Other' |
| | ), |
| | row_heights=[0.5, 0.2, 0.15, 0.15] |
| | ) |
| |
|
| | |
| | fig.add_trace( |
| | go.Candlestick( |
| | x=data.index, |
| | open=data['Open'], |
| | high=data['High'], |
| | low=data['Low'], |
| | close=data['Close'], |
| | name='Price' |
| | ), |
| | row=1, col=1 |
| | ) |
| |
|
| | |
| | colors = ["red", "yellow", "green", "purple", "orange", "brown", "pink", "gray", "cyan", "magenta","teal", "navy", "darkgreen", "darkorange", "darkviolet", "darkslateblue", "darkred", "darkgoldenrod", "darkturquoise", "darkorchid", "darkcyan"] |
| | color_idx = 0 |
| |
|
| | |
| | trend_indicators = ['SMA', 'EMA', 'HMA', 'WMA', 'KAMA', 'FRAMA', 'EVWMA', 'VWAP', 'DEMA', 'ZLEMA', 'SMM', 'SSMA', 'TEMA', 'TRIMA'] |
| | for name in trend_indicators: |
| | if name in indicators: |
| | fig.add_trace( |
| | go.Scatter( |
| | x=data.index, |
| | y=indicators[name].fillna(method='ffill'), |
| | mode='lines', |
| | name=name, |
| | line=dict(color=colors[color_idx % len(colors)]) |
| | ), |
| | row=1, col=1 |
| | ) |
| | color_idx += 1 |
| |
|
| | |
| | if 'Bollinger' in indicators: |
| | bb = indicators['Bollinger'] |
| | fig.add_trace( |
| | go.Scatter( |
| | x=data.index, |
| | y=bb['BB_UPPER'].fillna(method='ffill'), |
| | mode='lines', |
| | name='BB Upper', |
| | line=dict(color='lightblue', dash='dash') |
| | ), |
| | row=1, col=1 |
| | ) |
| | fig.add_trace( |
| | go.Scatter( |
| | x=data.index, |
| | y=bb['BB_LOWER'].fillna(method='ffill'), |
| | mode='lines', |
| | name='BB Lower', |
| | line=dict(color='lightblue', dash='dash'), |
| | fill='tonexty', |
| | fillcolor='rgba(173, 216, 230, 0.2)' |
| | ), |
| | row=1, col=1 |
| | ) |
| | |
| | if 'SAR' in indicators: |
| | fig.add_trace( |
| | go.Scatter(x=data.index, y=indicators['SAR'].fillna(method='ffill'), mode='markers', name='SAR', marker=dict(size=5, color='darkred')), |
| | row=1, col=1 |
| | ) |
| |
|
| | if 'KC' in indicators: |
| | kc = indicators['KC'] |
| | fig.add_trace( |
| | go.Scatter(x=data.index, y=kc['KC_UPPER'].fillna(method='ffill'), name='KC Upper', line=dict(color='orange')), |
| | row=1, col=1 |
| | ) |
| | fig.add_trace( |
| | go.Scatter(x=data.index, y=kc['KC_LOWER'].fillna(method='ffill'), name='KC Lower', line=dict(color='orange')), |
| | row=1, col=1 |
| | ) |
| | fig.add_trace( |
| | go.Scatter(x=data.index, y=kc['KC_MIDDLE'].fillna(method='ffill'), name='KC Middle', line=dict(color='gray', dash='dot')), |
| | row=1, col=1 |
| | ) |
| |
|
| | if 'DC' in indicators: |
| | dc = indicators['DC'] |
| | fig.add_trace( |
| | go.Scatter(x=data.index, y=dc['DC_U'].fillna(method='ffill'), name='DC Upper', line=dict(color='green')), |
| | row=1, col=1 |
| | ) |
| | fig.add_trace( |
| | go.Scatter(x=data.index, y=dc['DC_L'].fillna(method='ffill'), name='DC Lower', line=dict(color='green')), |
| | row=1, col=1 |
| | ) |
| | fig.add_trace( |
| | go.Scatter(x=data.index, y=dc['DC_M'].fillna(method='ffill'), name='DC Middle', line=dict(color='limegreen', dash='dot')), |
| | row=1, col=1 |
| | ) |
| |
|
| | if 'Chandelier' in indicators: |
| | ce = indicators['Chandelier'] |
| | fig.add_trace( |
| | go.Scatter(x=data.index, y=ce['CHANDELIER_Long'].fillna(method='ffill'), name='Chandelier Long', line=dict(color='darkred')), |
| | row=1, col=1 |
| | ) |
| | fig.add_trace( |
| | go.Scatter(x=data.index, y=ce['CHANDELIER_Short'].fillna(method='ffill'), name='Chandelier Short', line=dict(color='darkgreen')), |
| | row=1, col=1 |
| | ) |
| |
|
| | if 'APZ' in indicators: |
| | apz = indicators['APZ'] |
| | fig.add_trace( |
| | go.Scatter(x=data.index, y=apz['APZ_UPPER'].fillna(method='ffill'), name='APZ Upper', line=dict(color='orange', dash='dot')), |
| | row=1, col=1 |
| | ) |
| | fig.add_trace( |
| | go.Scatter(x=data.index, y=apz['APZ_LOWER'].fillna(method='ffill'), name='APZ Lower', line=dict(color='coral', dash='dot')), |
| | row=1, col=1 |
| | ) |
| |
|
| | if 'Ichimoku' in indicators: |
| | ichimoku = indicators['Ichimoku'] |
| | fig.add_trace( |
| | go.Scatter(x=data.index, y=ichimoku['TENKAN'].fillna(method='ffill'), name='Tenkan-sen', line=dict(color='blue')), |
| | row=1, col=1 |
| | ) |
| | fig.add_trace( |
| | go.Scatter(x=data.index, y=ichimoku['KIJUN'].fillna(method='ffill'), name='Kijun-sen', line=dict(color='red')), |
| | row=1, col=1 |
| | ) |
| | fig.add_trace( |
| | go.Scatter(x=data.index, y=ichimoku['SENKOU_A'].fillna(method='ffill'), name='Senkou A', line=dict(color='green')), |
| | row=1, col=1 |
| | ) |
| | fig.add_trace( |
| | go.Scatter(x=data.index, y=ichimoku['SENKOU_B'].fillna(method='ffill'), name='Senkou B', line=dict(color='red'), fill='tonexty', fillcolor='rgba(0, 255, 0, 0.2)'), |
| | row=1, col=1 |
| | ) |
| | fig.add_trace( |
| | go.Scatter(x=data.index, y=ichimoku['CHIKOU'].fillna(method='ffill'), name='Chikou Span', line=dict(color='purple')), |
| | row=1, col=1 |
| | ) |
| |
|
| | if 'Pivot' in indicators: |
| | pivot = indicators['Pivot'] |
| | for col in ['pivot', 'r1', 'r2', 'r3', 's1', 's2', 's3']: |
| | fig.add_trace( |
| | go.Scatter(x=data.index, y=pivot[col].fillna(method='ffill'), name=f'Pivot {col.upper()}', line=dict(dash='dash')), |
| | row=1, col=1 |
| | ) |
| |
|
| | if 'Pivot_Fib' in indicators: |
| | pivot_fib = indicators['Pivot_Fib'] |
| | for col in ['pivot', 'r1', 'r2', 'r3', 's1', 's2', 's3']: |
| | fig.add_trace( |
| | go.Scatter(x=data.index, y=pivot_fib[col].fillna(method='ffill'), name=f'Fib Pivot {col.upper()}', line=dict(dash='dot')), |
| | row=1, col=1 |
| | ) |
| |
|
| | if 'PSAR' in indicators: |
| | psar = indicators['PSAR'] |
| | fig.add_trace( |
| | go.Scatter(x=data.index, y=psar['psar'].fillna(method='ffill'), name='PSAR', mode='markers', marker=dict(size=5, color='blue')), |
| | row=1, col=1 |
| | ) |
| | fig.add_trace( |
| | go.Scatter(x=data.index, y=psar['psarbull'].fillna(method='ffill'), name='PSAR Bull', mode='markers', marker=dict(size=5, color='green')), |
| | row=1, col=1 |
| | ) |
| | fig.add_trace( |
| | go.Scatter(x=data.index, y=psar['psarbear'].fillna(method='ffill'), name='PSAR Bear', mode='markers', marker=dict(size=5, color='red')), |
| | row=1, col=1 |
| | ) |
| | |
| | if 'SMM' in indicators: |
| | fig.add_trace( |
| | go.Scatter(x=data.index, y=indicators['SMM'].fillna(method='ffill'), name='SMM', line=dict(color='darkcyan')), |
| | row=1, col=1 |
| | ) |
| |
|
| | if 'SSMA' in indicators: |
| | fig.add_trace( |
| | go.Scatter(x=data.index, y=indicators['SSMA'].fillna(method='ffill'), name='SSMA', line=dict(color='indigo')), |
| | row=1, col=1 |
| | ) |
| | |
| | if 'TRIX' in indicators: |
| | fig.add_trace( |
| | go.Scatter(x=data.index, y=indicators['TRIX'].fillna(method='ffill'), name='TRIX', line=dict(color='darkorange')), |
| | row=4, col=1 |
| | ) |
| |
|
| | |
| | fig.add_trace( |
| | go.Bar( |
| | x=data.index, |
| | y=data['Volume'], |
| | name='Volume', |
| | marker_color='lightblue' |
| | ), |
| | row=2, col=1 |
| | ) |
| |
|
| | |
| | if 'RSI' in indicators: |
| | fig.add_trace( |
| | go.Scatter(x=data.index, y=indicators['RSI'].fillna(method='ffill'), mode='lines', name='RSI', line=dict(color='purple')), |
| | row=3, col=1 |
| | ) |
| | fig.add_hline(y=70, line_dash="dash", line_color="red", row=3, col=1) |
| | fig.add_hline(y=30, line_dash="dash", line_color="green", row=3, col=1) |
| |
|
| | if 'StochRSI' in indicators: |
| | fig.add_trace( |
| | go.Scatter(x=data.index, y=indicators['StochRSI'].fillna(method='ffill'), mode='lines', name='StochRSI', line=dict(color='orange')), |
| | row=3, col=1 |
| | ) |
| | fig.add_hline(y=80, line_dash="dash", line_color="red", row=3, col=1) |
| | fig.add_hline(y=20, line_dash="dash", line_color="green", row=3, col=1) |
| |
|
| | if 'CCI' in indicators: |
| | fig.add_trace( |
| | go.Scatter(x=data.index, y=indicators['CCI'].fillna(method='ffill'), mode='lines', name='CCI', line=dict(color='blue')), |
| | row=3, col=1 |
| | ) |
| | fig.add_hline(y=100, line_dash="dash", line_color="red", row=3, col=1) |
| | fig.add_hline(y=-100, line_dash="dash", line_color="green", row=3, col=1) |
| |
|
| | if 'ADX' in indicators: |
| | fig.add_trace( |
| | go.Scatter(x=data.index, y=indicators['ADX'].fillna(method='ffill'), mode='lines', name='ADX', line=dict(color='cyan')), |
| | row=3, col=1 |
| | ) |
| | fig.add_hline(y=25, line_dash="dash", line_color="gray", row=3, col=1) |
| |
|
| | if 'Fisher' in indicators: |
| | fig.add_trace( |
| | go.Scatter(x=data.index, y=indicators['Fisher'].fillna(method='ffill'), mode='lines', name='Fisher Transform', line=dict(color='magenta')), |
| | row=3, col=1 |
| | ) |
| |
|
| | if 'AO' in indicators: |
| | fig.add_trace( |
| | go.Scatter(x=data.index, y=indicators['AO'].fillna(method='ffill'), mode='lines', name='Awesome Oscillator', line=dict(color='green')), |
| | row=3, col=1 |
| | ) |
| | fig.add_hline(y=0, line_dash="dash", line_color="gray", row=3, col=1) |
| |
|
| | if 'MI' in indicators: |
| | fig.add_trace( |
| | go.Scatter(x=data.index, y=indicators['MI'].fillna(method='ffill'), mode='lines', name='Mass Index', line=dict(color='purple')), |
| | row=3, col=1 |
| | ) |
| | fig.add_hline(y=27, line_dash="dash", line_color="red", row=3, col=1) |
| |
|
| | if 'IFT_RSI' in indicators: |
| | fig.add_trace( |
| | go.Scatter(x=data.index, y=indicators['IFT_RSI'].fillna(method='ffill'), mode='lines', name='IFT RSI', line=dict(color='orange')), |
| | row=3, col=1 |
| | ) |
| |
|
| | |
| | if 'MACD' in indicators: |
| | macd = indicators['MACD'] |
| | macd_line = macd['MACD'] |
| | signal_line = macd['SIGNAL'] |
| | macd_histogram = macd_line - signal_line |
| | fig.add_trace( |
| | go.Scatter(x=data.index, y=macd_line.fillna(method='ffill'), mode='lines', name='MACD', line=dict(color='#04c6fc')), |
| | row=4, col=1 |
| | ) |
| | fig.add_trace( |
| | go.Scatter(x=data.index, y=signal_line.fillna(method='ffill'), mode='lines', name='MACD Signal', line=dict(color='blue', dash='dash')), |
| | row=4, col=1 |
| | ) |
| | fig.add_trace( |
| | go.Bar(x=data.index, y=macd_histogram.fillna(0), name='MACD Histogram', marker_color=['green' if val >= 0 else 'red' for val in macd_histogram]), |
| | row=4, col=1 |
| | ) |
| | |
| | if 'MOM' in indicators: |
| | fig.add_trace( |
| | go.Scatter(x=data.index, y=indicators['MOM'].fillna(method='ffill'), name='MOM', line=dict(color='lime')), |
| | row=4, col=1 |
| | ) |
| | |
| | if 'WOBV' in indicators: |
| | fig.add_trace( |
| | go.Scatter(x=data.index, y=indicators['WOBV'].fillna(method='ffill'), name='WOBV', line=dict(color='darkblue', dash='dot')), |
| | row=4, col=1 |
| | ) |
| |
|
| |
|
| | if 'DYMI' in indicators: |
| | fig.add_trace( |
| | go.Scatter(x=data.index, y=indicators['DYMI'].fillna(method='ffill'), name='DYMI', line=dict(color='crimson')), |
| | row=4, col=1 |
| | ) |
| |
|
| | if 'TSI' in indicators: |
| | tsi = indicators['TSI'] |
| | fig.add_trace( |
| | go.Scatter(x=data.index, y=tsi['TSI'].fillna(method='ffill'), name='TSI', line=dict(color='blue')), |
| | row=4, col=1 |
| | ) |
| | fig.add_trace( |
| | go.Scatter(x=data.index, y=tsi['signal'].fillna(method='ffill'), name='TSI Signal', line=dict(color='blue', dash='dash')), |
| | row=4, col=1 |
| | ) |
| |
|
| | if 'KST' in indicators: |
| | kst = indicators['KST'] |
| | fig.add_trace( |
| | go.Scatter(x=data.index, y=kst['KST'].fillna(method='ffill'), name='KST', line=dict(color='purple')), |
| | row=4, col=1 |
| | ) |
| | fig.add_trace( |
| | go.Scatter(x=data.index, y=kst['signal'].fillna(method='ffill'), name='KST Signal', line=dict(color='purple', dash='dot')), |
| | row=4, col=1 |
| | ) |
| |
|
| | if 'PPO' in indicators: |
| | ppo = indicators['PPO'] |
| | fig.add_trace( |
| | go.Scatter(x=data.index, y=ppo['PPO'].fillna(method='ffill'), name='PPO', line=dict(color='cyan')), |
| | row=4, col=1 |
| | ) |
| | fig.add_trace( |
| | go.Scatter(x=data.index, y=ppo['PPO_signal'].fillna(method='ffill'), name='PPO Signal', line=dict(color='cyan', dash='dash')), |
| | row=4, col=1 |
| | ) |
| | fig.add_trace( |
| | go.Bar(x=data.index, y=ppo['PPO_histo'].fillna(0), name='PPO Histogram', marker_color=['green' if val >= 0 else 'red' for val in ppo['PPO_histo']]), |
| | row=4, col=1 |
| | ) |
| |
|
| | if 'CMO' in indicators: |
| | fig.add_trace( |
| | go.Scatter(x=data.index, y=indicators['CMO'].fillna(method='ffill'), name='CMO', line=dict(color='orange')), |
| | row=4, col=1 |
| | ) |
| | fig.add_hline(y=50, line_dash="dash", line_color="red", row=4, col=1) |
| | fig.add_hline(y=-50, line_dash="dash", line_color="green", row=4, col=1) |
| |
|
| | if 'ROC' in indicators: |
| | fig.add_trace( |
| | go.Scatter(x=data.index, y=indicators['ROC'].fillna(method='ffill'), name='ROC', line=dict(color='green')), |
| | row=4, col=1 |
| | ) |
| | fig.add_hline(y=0, line_dash="dash", line_color="gray", row=4, col=1) |
| |
|
| | if 'UO' in indicators: |
| | fig.add_trace( |
| | go.Scatter(x=data.index, y=indicators['UO'].fillna(method='ffill'), name='Ultimate Oscillator', line=dict(color='purple')), |
| | row=4, col=1 |
| | ) |
| | fig.add_hline(y=70, line_dash="dash", line_color="red", row=4, col=1) |
| | fig.add_hline(y=30, line_dash="dash", line_color="green", row=4, col=1) |
| |
|
| | if 'OBV' in indicators: |
| | fig.add_trace( |
| | go.Scatter(x=data.index, y=indicators['OBV'].fillna(method='ffill'), name='OBV', line=dict(color='blue')), |
| | row=4, col=1 |
| | ) |
| |
|
| | if 'ADL' in indicators: |
| | fig.add_trace( |
| | go.Scatter(x=data.index, y=indicators['ADL'].fillna(method='ffill'), name='ADL', line=dict(color='cyan')), |
| | row=4, col=1 |
| | ) |
| |
|
| | if 'EFI' in indicators: |
| | fig.add_trace( |
| | go.Scatter(x=data.index, y=indicators['EFI'].fillna(method='ffill'), name='EFI', line=dict(color='magenta')), |
| | row=4, col=1 |
| | ) |
| |
|
| | if 'EMV' in indicators: |
| | fig.add_trace( |
| | go.Scatter(x=data.index, y=indicators['EMV'].fillna(method='ffill'), name='EMV', line=dict(color='orange')), |
| | row=4, col=1 |
| | ) |
| |
|
| | if 'MFI' in indicators: |
| | fig.add_trace( |
| | go.Scatter(x=data.index, y=indicators['MFI'].fillna(method='ffill'), name='MFI', line=dict(color='blue')), |
| | row=4, col=1 |
| | ) |
| | fig.add_hline(y=80, line_dash="dash", line_color="red", row=4, col=1) |
| | fig.add_hline(y=20, line_dash="dash", line_color="green", row=4, col=1) |
| |
|
| | if 'VPT' in indicators: |
| | fig.add_trace( |
| | go.Scatter(x=data.index, y=indicators['VPT'].fillna(method='ffill'), name='VPT', line=dict(color='blue', dash='dot')), |
| | row=4, col=1 |
| | ) |
| |
|
| | if 'FVE' in indicators: |
| | fig.add_trace( |
| | go.Scatter(x=data.index, y=indicators['FVE'].fillna(method='ffill'), name='FVE', line=dict(color='blue', dash='dot')), |
| | row=4, col=1 |
| | ) |
| |
|
| | if 'VZO' in indicators: |
| | fig.add_trace( |
| | go.Scatter(x=data.index, y=indicators['VZO'].fillna(method='ffill'), name='VZO', line=dict(color='blue', dash='dot')), |
| | row=4, col=1 |
| | ) |
| | fig.add_hline(y=40, line_dash="dash", line_color="green", row=4, col=1) |
| | fig.add_hline(y=5, line_dash="dash", line_color="red", row=4, col=1) |
| | fig.add_hline(y=-5, line_dash="dash", line_color="red", row=4, col=1) |
| | fig.add_hline(y=-40, line_dash="dash", line_color="green", row=4, col=1) |
| |
|
| | if 'WTO' in indicators: |
| | wto = indicators['WTO'] |
| | fig.add_trace( |
| | go.Scatter(x=data.index, y=wto['WT1'].fillna(method='ffill'), name='WTO WT1', line=dict(color='cyan')), |
| | row=4, col=1 |
| | ) |
| | fig.add_trace( |
| | go.Scatter(x=data.index, y=wto['WT2'].fillna(method='ffill'), name='WTO WT2', line=dict(color='cyan', dash='dash')), |
| | row=4, col=1 |
| | ) |
| |
|
| | if 'Coppock' in indicators: |
| | fig.add_trace( |
| | go.Scatter(x=data.index, y=indicators['Coppock'].fillna(method='ffill'), name='Coppock Curve', line=dict(color='purple')), |
| | row=4, col=1 |
| | ) |
| | fig.add_hline(y=0, line_dash="dash", line_color="gray", row=4, col=1) |
| |
|
| | if 'BASP' in indicators: |
| | basp = indicators['BASP'] |
| | fig.add_trace( |
| | go.Scatter(x=data.index, y=basp['Buy'].fillna(method='ffill'), name='BASP Buy', line=dict(color='green')), |
| | row=4, col=1 |
| | ) |
| | fig.add_trace( |
| | go.Scatter(x=data.index, y=basp['Sell'].fillna(method='ffill'), name='BASP Sell', line=dict(color='red')), |
| | row=4, col=1 |
| | ) |
| |
|
| | if 'BASPN' in indicators: |
| | baspn = indicators['BASPN'] |
| | fig.add_trace( |
| | go.Scatter(x=data.index, y=baspn['BASPN_Buy'].fillna(method='ffill'), name='BASPN Buy', line=dict(color='limegreen')), |
| | row=4, col=1 |
| | ) |
| | fig.add_trace( |
| | go.Scatter(x=data.index, y=baspn['BASPN_Sell'].fillna(method='ffill'), name='BASPN Sell', line=dict(color='coral')), |
| | row=4, col=1 |
| | ) |
| |
|
| | if 'DMI' in indicators: |
| | dmi = indicators['DMI'] |
| | fig.add_trace( |
| | go.Scatter(x=data.index, y=dmi['+DI'].fillna(method='ffill'), name='+DI', line=dict(color='blue')), |
| | row=4, col=1 |
| | ) |
| | fig.add_trace( |
| | go.Scatter(x=data.index, y=dmi['-DI'].fillna(method='ffill'), name='-DI', line=dict(color='red')), |
| | row=4, col=1 |
| | ) |
| |
|
| | if 'EBBP' in indicators: |
| | ebbp = indicators['EBBP'] |
| | fig.add_trace( |
| | go.Scatter(x=data.index, y=ebbp['Bull'].fillna(method='ffill'), name='Bull Power', line=dict(color='green')), |
| | row=4, col=1 |
| | ) |
| | fig.add_trace( |
| | go.Scatter(x=data.index, y=ebbp['Bear'].fillna(method='ffill'), name='Bear Power', line=dict(color='red')), |
| | row=4, col=1 |
| | ) |
| |
|
| | if 'ATR' in indicators: |
| | fig.add_trace( |
| | go.Scatter(x=data.index, y=indicators['ATR'].fillna(method='ffill'), name='ATR', line=dict(color='blue')), |
| | row=4, col=1 |
| | ) |
| | |
| | if 'QSTICK' in indicators: |
| | fig.add_trace( |
| | go.Scatter(x=data.index, y=indicators['QSTICK'].fillna(method='ffill'), name='Q Stick', line=dict(color='gold')), |
| | row=4, col=1 |
| | ) |
| |
|
| | if 'VBM' in indicators: |
| | fig.add_trace( |
| | go.Scatter(x=data.index, y=indicators['VBM'].fillna(method='ffill'), name='VBM', line=dict(color='orange')), |
| | row=4, col=1 |
| | ) |
| | |
| | if 'CFI' in indicators: |
| | fig.add_trace( |
| | go.Scatter(x=data.index, y=indicators['CFI'].fillna(method='ffill'), name='CFI', line=dict(color='deepskyblue')), |
| | row=4, col=1 |
| | ) |
| |
|
| |
|
| | |
| | |
| | fig.update_layout( |
| | title=f'{symbol.upper()} - Technical Analysis', |
| | xaxis_rangeslider_visible=False, |
| | height=800, |
| | showlegend=True |
| | ) |
| | |
| | st.plotly_chart(fig, use_container_width=True) |
| | |
| | |
| | st.subheader("π Indicator Values") |
| | |
| | |
| | tab1, tab2, tab3, tab4, tab5 = st.tabs(["Trend", "Momentum", "Volume", "Volatility", "Oscillators"]) |
| | |
| | with tab1: |
| | st.markdown("### Trend Indicators") |
| | trend_cols = st.columns(3) |
| | col_idx = 0 |
| | |
| | for name, indicator in indicators.items(): |
| | if name in ['SMA', 'EMA', 'HMA', 'WMA', 'KAMA', 'FRAMA', 'EVWMA', 'VWAP']: |
| | with trend_cols[col_idx % 3]: |
| | if isinstance(indicator, pd.Series): |
| | st.metric(name, f"{indicator.iloc[-1]:.2f}") |
| | col_idx += 1 |
| | |
| | with tab2: |
| | st.markdown("### Momentum Indicators") |
| | momentum_cols = st.columns(3) |
| | col_idx = 0 |
| | |
| | for name, indicator in indicators.items(): |
| | if name in ['RSI', 'StochRSI', 'CMO', 'ROC', 'UO']: |
| | with momentum_cols[col_idx % 3]: |
| | if isinstance(indicator, pd.Series): |
| | st.metric(name, f"{indicator.iloc[-1]:.2f}") |
| | col_idx += 1 |
| | |
| | with tab3: |
| | st.markdown("### Volume Indicators") |
| | volume_cols = st.columns(3) |
| | col_idx = 0 |
| | |
| | for name, indicator in indicators.items(): |
| | if name in ['OBV', 'ADL', 'EFI', 'EMV', 'MFI', 'VPT', 'FVE', 'VZO']: |
| | with volume_cols[col_idx % 3]: |
| | if isinstance(indicator, pd.Series): |
| | st.metric(name, f"{indicator.iloc[-1]:.2f}") |
| | col_idx += 1 |
| | |
| | with tab4: |
| | st.markdown("### Volatility Indicators") |
| | volatility_cols = st.columns(3) |
| | col_idx = 0 |
| | |
| | for name, indicator in indicators.items(): |
| | if name in ['ATR', 'PSAR']: |
| | with volatility_cols[col_idx % 3]: |
| | if isinstance(indicator, pd.Series): |
| | st.metric(name, f"{indicator.iloc[-1]:.2f}") |
| | col_idx += 1 |
| | |
| | with tab5: |
| | st.markdown("### Oscillators") |
| | osc_cols = st.columns(3) |
| | col_idx = 0 |
| | |
| | for name, indicator in indicators.items(): |
| | if name in ['ADX', 'CCI', 'Fisher', 'AO', 'MI']: |
| | with osc_cols[col_idx % 3]: |
| | if isinstance(indicator, pd.Series): |
| | st.metric(name, f"{indicator.iloc[-1]:.2f}") |
| | col_idx += 1 |
| | |
| | |
| | with st.expander("π Raw Data"): |
| | st.dataframe(data.tail(50)) |
| | |
| | |
| | st.subheader("πΎ Download Data") |
| | |
| | |
| | combined_df = data.copy() |
| | for name, indicator in indicators.items(): |
| | if isinstance(indicator, pd.Series): |
| | combined_df[name] = indicator |
| | elif isinstance(indicator, pd.DataFrame): |
| | for col in indicator.columns: |
| | combined_df[f"{name}_{col}"] = indicator[col] |
| | |
| | csv = combined_df.to_csv() |
| | st.download_button( |
| | label="Download CSV", |
| | data=csv, |
| | file_name=f'{symbol}_technical_analysis.csv', |
| | mime='text/csv' |
| | ) |
| | |
| | except Exception as e: |
| | st.error(f"An error occurred: {str(e)}") |
| | st.error("Please check your internet connection and try again.") |
| |
|
| | |
| | else: |
| | st.markdown(""" |
| | ## π How to Use This Dashboard |
| | |
| | 1. **Enter a stock symbol** in the sidebar (e.g., AAPL, GOOGL, MSFT) for Indian Stocks, use NSE symbols like RELIANCE.NS |
| | or BHEL.NS. |
| | 2. **Select time period and interval** for the data |
| | 3. **Choose technical indicators** you want to analyze |
| | 4. **Adjust parameters** for the indicators |
| | 5. **Click "Analyze Stock"** to generate the analysis |
| | |
| | ### π Available Indicators |
| | |
| | This dashboard includes **50+ technical indicators** across multiple categories: |
| | |
| | - **Trend Indicators**: SMA, EMA, HMA, WMA, KAMA, FRAMA, EVWMA, VWAP |
| | - **Momentum Indicators**: RSI, MACD, Stochastic RSI, CMO, ROC, TSI, KST, PPO, UO |
| | - **Volume Indicators**: OBV, ADL, Chaikin Oscillator, EFI, EMV, MFI, VPT, FVE, VZO |
| | - **Volatility Indicators**: Bollinger Bands, Keltner Channels, Donchian Channels, ATR, Chandelier Exit, Parabolic SAR |
| | - **Oscillators**: ADX, CCI, Fisher Transform, Awesome Oscillator, Mass Index, Wave Trend Oscillator |
| | - **Complex Indicators**: Ichimoku Cloud, Pivot Points, Fibonacci Pivots, BASP, DMI, Elder Bull/Bear Power |
| | |
| | ### π‘ Tips |
| | |
| | - Use multiple indicators together for better analysis |
| | - Adjust parameters based on your trading timeframe |
| | - Download the data for further analysis |
| | - Check different time periods to understand trends |
| | """) |
| |
|
| | |
| | st.markdown("---") |
| | st.markdown("**Technical Analysis Dashboard** | Built with Streamlit & Python | Data from Yahoo Finance") |
| | st.markdown("---") |
| | st.markdown("**Made By Zane Vijay Falcao**") |