Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -350,25 +350,25 @@ def generate_trading_signals(df):
|
|
| 350 |
|
| 351 |
# Ultra-strict RSI Signal - Extreme thresholds
|
| 352 |
df['RSI_Signal'] = np.where(df['RSI'] < 15, 1, 0)
|
| 353 |
-
df['RSI_Signal'] = np.where(df['RSI'] >
|
| 354 |
|
| 355 |
# Ultra-strict Bollinger Bands Signal - Require extreme deviations
|
| 356 |
df['BB_Signal'] = np.where(df['Close'] < df['LowerBB'] * 0.97, 1, 0)
|
| 357 |
df['BB_Signal'] = np.where(df['Close'] > df['UpperBB'] * 1.03, -1, df['BB_Signal'])
|
| 358 |
|
| 359 |
# Ultra-strict Stochastic Signal - Extreme overbought/oversold conditions
|
| 360 |
-
df['Stochastic_Signal'] = np.where((df['SlowK'] <
|
| 361 |
df['Stochastic_Signal'] = np.where((df['SlowK'] > 95) & (df['SlowD'] > 95), -1, df['Stochastic_Signal'])
|
| 362 |
|
| 363 |
# Ultra-strict CMF Signal - Require stronger money flow confirmation
|
| 364 |
-
df['CMF_Signal'] = np.where(df['CMF'] > 0.
|
| 365 |
|
| 366 |
# Ultra-strict CCI Signal - Require extreme deviations
|
| 367 |
-
df['CCI_Signal'] = np.where(df['CCI'] < -
|
| 368 |
-
df['CCI_Signal'] = np.where(df['CCI'] >
|
| 369 |
|
| 370 |
# Combined signal for ultra-strict confirmations
|
| 371 |
-
df['Combined_Signal'] = df[['RSI_Signal', 'BB_Signal',
|
| 372 |
'Stochastic_Signal', 'CMF_Signal', 'CCI_Signal']].sum(axis=1)
|
| 373 |
|
| 374 |
return df
|
|
@@ -464,17 +464,18 @@ def plot_individual_signals(df, ticker):
|
|
| 464 |
|
| 465 |
|
| 466 |
signal_colors = {
|
| 467 |
-
'
|
| 468 |
-
'
|
| 469 |
-
'
|
| 470 |
-
'
|
| 471 |
-
'
|
|
|
|
| 472 |
}
|
| 473 |
|
| 474 |
|
| 475 |
|
| 476 |
# Add buy/sell signals for each indicator
|
| 477 |
-
signal_names = ['RSI_Signal', 'BB_Signal',
|
| 478 |
'Stochastic_Signal', 'CMF_Signal',
|
| 479 |
'CCI_Signal']
|
| 480 |
|
|
|
|
| 350 |
|
| 351 |
# Ultra-strict RSI Signal - Extreme thresholds
|
| 352 |
df['RSI_Signal'] = np.where(df['RSI'] < 15, 1, 0)
|
| 353 |
+
df['RSI_Signal'] = np.where(df['RSI'] > 90, -1, df['RSI_Signal'])
|
| 354 |
|
| 355 |
# Ultra-strict Bollinger Bands Signal - Require extreme deviations
|
| 356 |
df['BB_Signal'] = np.where(df['Close'] < df['LowerBB'] * 0.97, 1, 0)
|
| 357 |
df['BB_Signal'] = np.where(df['Close'] > df['UpperBB'] * 1.03, -1, df['BB_Signal'])
|
| 358 |
|
| 359 |
# Ultra-strict Stochastic Signal - Extreme overbought/oversold conditions
|
| 360 |
+
df['Stochastic_Signal'] = np.where((df['SlowK'] < 10) & (df['SlowD'] < 10), 1, 0)
|
| 361 |
df['Stochastic_Signal'] = np.where((df['SlowK'] > 95) & (df['SlowD'] > 95), -1, df['Stochastic_Signal'])
|
| 362 |
|
| 363 |
# Ultra-strict CMF Signal - Require stronger money flow confirmation
|
| 364 |
+
df['CMF_Signal'] = np.where(df['CMF'] > 0.4, -1, np.where(df['CMF'] < -0.4, 1, 0))
|
| 365 |
|
| 366 |
# Ultra-strict CCI Signal - Require extreme deviations
|
| 367 |
+
df['CCI_Signal'] = np.where(df['CCI'] < -200, 1, 0)
|
| 368 |
+
df['CCI_Signal'] = np.where(df['CCI'] > 200, -1, df['CCI_Signal'])
|
| 369 |
|
| 370 |
# Combined signal for ultra-strict confirmations
|
| 371 |
+
df['Combined_Signal'] = df[['MACD_Signal','RSI_Signal', 'BB_Signal',
|
| 372 |
'Stochastic_Signal', 'CMF_Signal', 'CCI_Signal']].sum(axis=1)
|
| 373 |
|
| 374 |
return df
|
|
|
|
| 464 |
|
| 465 |
|
| 466 |
signal_colors = {
|
| 467 |
+
'MACD_Signal': {'buy': 'purple', 'sell': 'lightpink'}, # Light purple / Pale butter
|
| 468 |
+
'RSI_Signal': {'buy': 'purple', 'sell': 'lightpink'}, # Light purple / Pale butter
|
| 469 |
+
'BB_Signal': {'buy': 'purple', 'sell': 'lightpink'}, # Purple / Chiffon yellow
|
| 470 |
+
'Stochastic_Signal': {'buy': 'purple', 'sell': 'lightpink'}, # Purple / Corn silk
|
| 471 |
+
'CMF_Signal': {'buy': 'purple', 'sell': 'lightpink'}, # Deep purple / Lemon chiffon
|
| 472 |
+
'CCI_Signal': {'buy': 'purple', 'sell': 'lightpink'} # Dark purple / Soft maize
|
| 473 |
}
|
| 474 |
|
| 475 |
|
| 476 |
|
| 477 |
# Add buy/sell signals for each indicator
|
| 478 |
+
signal_names = ['MACD_Signal', 'RSI_Signal', 'BB_Signal',
|
| 479 |
'Stochastic_Signal', 'CMF_Signal',
|
| 480 |
'CCI_Signal']
|
| 481 |
|