JayLacoma commited on
Commit
53f002f
·
verified ·
1 Parent(s): db0cb1a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +44 -2
app.py CHANGED
@@ -361,7 +361,7 @@ def generate_trading_signals(df):
361
  df['Stochastic_Signal'] = np.where((df['SlowK'] > 100) & (df['SlowD'] > 100), -1, df['Stochastic_Signal'])
362
 
363
  # Less strict CMF Signal - Use ±0.1 instead of ±0.4
364
- df['CMF_Signal'] = np.where(df['CMF'] > 0.3, -1, np.where(df['CMF'] < -0.3, 1, 0))
365
 
366
  # Less strict CCI Signal - Standard thresholds (±100 instead of ±220)
367
  df['CCI_Signal'] = np.where(df['CCI'] < -100, 1, 0)
@@ -373,7 +373,7 @@ def generate_trading_signals(df):
373
 
374
  return df
375
 
376
- def plot_combined_signals(df, ticker):
377
  # Create a figure
378
  fig = go.Figure()
379
 
@@ -445,6 +445,48 @@ def plot_combined_signals(df, ticker):
445
 
446
  return fig
447
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
448
  def plot_individual_signals(df, ticker):
449
  # Create a figure
450
  fig = go.Figure()
 
361
  df['Stochastic_Signal'] = np.where((df['SlowK'] > 100) & (df['SlowD'] > 100), -1, df['Stochastic_Signal'])
362
 
363
  # Less strict CMF Signal - Use ±0.1 instead of ±0.4
364
+ df['CMF_Signal'] = np.where(df['CMF'] > 0.4, -1, np.where(df['CMF'] < -0.4, 1, 0))
365
 
366
  # Less strict CCI Signal - Standard thresholds (±100 instead of ±220)
367
  df['CCI_Signal'] = np.where(df['CCI'] < -100, 1, 0)
 
373
 
374
  return df
375
 
376
+ def plot_combined(df, ticker):
377
  # Create a figure
378
  fig = go.Figure()
379
 
 
445
 
446
  return fig
447
 
448
+ import plotly.graph_objects as go
449
+
450
+ def plot_combined_signals(df, ticker):
451
+ """
452
+ Creates a focused plot of JUST the combined signal strength.
453
+ Bars are colored green for positive (buy) signals and red for negative (sell) signals.
454
+ """
455
+ # Create a new figure
456
+ fig = go.Figure()
457
+
458
+ # Define colors based on the signal value (positive/negative)
459
+ colors = ['#2ECC71' if val >= 0 else '#E74C3C' for val in df['Combined_Signal']]
460
+
461
+ # Add the bar chart for the combined signal
462
+ fig.add_trace(go.Bar(
463
+ x=df.index,
464
+ y=df['Combined_Signal'],
465
+ name='Signal Strength',
466
+ marker_color=colors,
467
+ # Add hover text for clarity
468
+ hovertemplate='<b>Date</b>: %{x}<br><b>Signal</b>: %{y}<extra></extra>'
469
+ ))
470
+
471
+ # Update the layout for a clean, focused look
472
+ fig.update_layout(
473
+ title={
474
+ 'text': f'Strength Indicator for {ticker}',
475
+ 'y':0.9,
476
+ 'x':0.5,
477
+ 'xanchor': 'center',
478
+ 'yanchor': 'top',
479
+ 'font': {'size': 20}
480
+ },
481
+ template='plotly_dark',
482
+ xaxis_title='Date',
483
+ yaxis_title='Signal Strength Score',
484
+ yaxis=dict(zeroline=True, zerolinewidth=2, zerolinecolor='gray'),
485
+ showlegend=False # Not needed for a single trace
486
+ )
487
+
488
+ return fig
489
+
490
  def plot_individual_signals(df, ticker):
491
  # Create a figure
492
  fig = go.Figure()