File size: 35,661 Bytes
f3d17b9 734c48c f3d17b9 734c48c |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 |
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")
# Import all technical indicators from your file
from technical_indicators import *
# Page configuration
st.set_page_config(
page_title="Technical Analysis Dashboard",
page_icon="π",
layout="wide",
initial_sidebar_state="expanded"
)
# Custom CSS for better styling
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)
# Title
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()
# Sidebar for inputs
with st.sidebar:
st.header("π Configuration")
# Stock symbol input
symbol = st.text_input("Stock Symbol", value="AAPL", help="Enter stock symbol (e.g., AAPL, GOOGL, MSFT)")
# Time period selection
period = st.selectbox(
"Time Period",
["1mo", "3mo", "6mo", "1y", "2y", "5y", "max"],
index=3
)
# Interval selection
interval = st.selectbox(
"Data Interval",
["1d", "5d", "1wk", "1mo"],
index=0
)
st.divider()
# Indicator Categories
st.header("π Select Indicators")
# Trend 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)")
# Momentum Indicators
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)")
# Volume Indicators
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)")
# Volatility Indicators
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)")
# Oscillators
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")
# Complex Indicators
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")
st.divider()
# Parameter settings
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)
# Main content area
if col3.button("π Analyze Stock", type="secondary", use_container_width=True):
try:
# Fetch data
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()
# Display basic info
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}")
# Calculate indicators
indicators = {}
# Trend 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)
# Momentum Indicators
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)
# Volume Indicators
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)
# Volatility Indicators
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)
# Oscillators
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)
# Complex Indicators
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)
# Create main price chart
fig = make_subplots(
rows=4, cols=1,
shared_xaxes=True,
vertical_spacing=0.05,
subplot_titles=('Price Chart', 'Volume', 'Oscillators', 'Additional Indicators'),
row_heights=[0.5, 0.2, 0.15, 0.15]
)
# Add candlestick chart
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
)
# Define colors for trend indicators to avoid repetition
colors = ["red", "yellow", "green", "purple", "orange", "brown", "pink", "gray", "cyan", "magenta"]
color_idx = 0
# Add trend indicators to price chart (row 1)
trend_indicators = ['SMA', 'EMA', 'HMA', 'WMA', 'KAMA', 'FRAMA', 'EVWMA', 'VWAP']
for name in trend_indicators:
if name in indicators:
fig.add_trace(
go.Scatter(
x=data.index,
y=indicators[name].fillna(method='ffill'), # Handle NaNs
mode='lines',
name=name,
line=dict(color=colors[color_idx % len(colors)])
),
row=1, col=1
)
color_idx += 1
# Add volatility indicators to price chart (row 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 '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
)
# Add volume (row 2)
fig.add_trace(
go.Bar(
x=data.index,
y=data['Volume'],
name='Volume',
marker_color='lightblue'
),
row=2, col=1
)
# Add oscillators to row 3
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
)
# Add momentum and volume indicators to row 4
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 '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
)
# Update layout
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)
# Display indicator values in tabs
st.subheader("π Indicator Values")
# Create tabs for different categories
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
# Raw data section
with st.expander("π Raw Data"):
st.dataframe(data.tail(50))
# Download section
st.subheader("πΎ Download Data")
# Combine all indicators into one DataFrame
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.")
# Instructions
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 **40+ 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
""")
# Footer
st.markdown("---")
st.markdown("**Technical Analysis Dashboard** | Built with Streamlit & Python | Data from Yahoo Finance")
st.markdown("---")
st.markdown("**Made By Zane Vijay Falcao**") |