Skip to content

Commit e285d9f

Browse files
committed
Add momentum confluence
1 parent 6dd5309 commit e285d9f

5 files changed

Lines changed: 782 additions & 3 deletions

File tree

README.md

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ pip install pyindicators
3636
* [Williams %R](#williams-r)
3737
* [Average Directional Index (ADX)](#average-directional-index-adx)
3838
* [Stochastic Oscillator (STO)](#stochastic-oscillator-sto)
39+
* [Momentum Confluence](#momentum-confluence)
3940
* [Volatility indicators](#volatility-indicators)
4041
* [Bollinger Bands (BB)](#bollinger-bands-bb)
4142
* [Bollinger Bands Overshoot](#bollinger-bands-overshoot)
@@ -541,6 +542,78 @@ pd_df.tail(10)
541542

542543
![STO](https://github.com/coding-kitties/PyIndicators/blob/main/static/images/indicators/sto.png)
543544

545+
#### Momentum Confluence
546+
547+
Momentum Confluence is a comprehensive multi-component oscillator that combines multiple technical analysis components to provide a powerful trend following and reversal detection system.
548+
549+
**Components:**
550+
1. **Money Flow**: Measures buying/selling liquidity entering the market (-100 to +100)
551+
2. **Thresholds**: Dynamic levels showing significant buying/selling activity
552+
3. **Overflow**: Detects excess buying/selling that predicts reversals
553+
4. **Trend Wave**: A highly reactive trend-following oscillator (0-100)
554+
5. **Real-Time Divergences**: Price vs oscillator divergence detection
555+
6. **Reversal Signals**: High-frequency (small dots) and strong (arrows) reversal signals
556+
7. **Confluence**: Combined signal strength from all components (-100 to +100)
557+
558+
```python
559+
def momentum_confluence(
560+
data: Union[PdDataFrame, PlDataFrame],
561+
money_flow_length: int = 14,
562+
trend_wave_length: int = 10,
563+
threshold_mult: float = 1.5,
564+
overflow_threshold: float = 0.8,
565+
divergence_lookback: int = 5,
566+
high_column: str = 'High',
567+
low_column: str = 'Low',
568+
close_column: str = 'Close',
569+
volume_column: str = 'Volume',
570+
...
571+
) -> Union[PdDataFrame, PlDataFrame]:
572+
```
573+
574+
Example
575+
576+
```python
577+
from pyindicators import (
578+
momentum_confluence,
579+
momentum_confluence_signal,
580+
get_momentum_confluence_stats
581+
)
582+
583+
# Calculate Momentum Confluence
584+
df = momentum_confluence(df)
585+
586+
# Generate trading signals
587+
df = momentum_confluence_signal(df)
588+
589+
# Get statistics
590+
stats = get_momentum_confluence_stats(df)
591+
print(f"Strong bullish reversals: {stats['strong_reversal_bullish_count']}")
592+
print(f"Divergences detected: {stats['divergence_bullish_count']}")
593+
```
594+
595+
**Output Columns:**
596+
- `money_flow`: Money flow oscillator (-100 to +100)
597+
- `mf_upper_threshold` / `mf_lower_threshold`: Dynamic threshold levels
598+
- `overflow_bullish` / `overflow_bearish`: Excess buying/selling (0 or 1)
599+
- `trend_wave`: Trend oscillator (0-100)
600+
- `trend_wave_signal`: Trend direction (1=bullish, -1=bearish, 0=neutral)
601+
- `divergence_bullish` / `divergence_bearish`: Divergence detection (0 or 1)
602+
- `reversal_bullish` / `reversal_bearish`: High-frequency reversal signals (0 or 1)
603+
- `reversal_strong_bullish` / `reversal_strong_bearish`: Strong reversal signals (0 or 1)
604+
- `confluence`: Combined signal strength (-100 to +100)
605+
- `mc_trend`: Overall trend direction (1=bullish, -1=bearish, 0=neutral)
606+
607+
**Signal Values (from momentum_confluence_signal):**
608+
- `2`: Strong bullish reversal signal
609+
- `1`: Bullish confluence
610+
- `0`: Neutral
611+
- `-1`: Bearish confluence
612+
- `-2`: Strong bearish reversal signal
613+
614+
![MOMENTUM_CONFLUENCE](https://github.com/coding-kitties/PyIndicators/blob/main/static/images/indicators/momentum_confluence.png)
615+
616+
544617
### Volatility indicators
545618

546619
Indicators that measure the rate of price movement, regardless of direction. They help to identify

pyindicators/__init__.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@
1616
order_blocks, ob_signal, get_active_order_blocks,
1717
market_structure_break, market_structure_ob,
1818
msb_signal, ob_quality_signal, get_market_structure_stats,
19-
market_structure_choch_bos, choch_bos_signal, get_choch_bos_stats
19+
market_structure_choch_bos, choch_bos_signal, get_choch_bos_stats,
20+
momentum_confluence, momentum_confluence_signal,
21+
get_momentum_confluence_stats
2022
)
2123
from .exceptions import PyIndicatorException
2224
from .date_range import DateRange
@@ -96,5 +98,8 @@ def get_version():
9698
'get_market_structure_stats',
9799
'market_structure_choch_bos',
98100
'choch_bos_signal',
99-
'get_choch_bos_stats'
101+
'get_choch_bos_stats',
102+
'momentum_confluence',
103+
'momentum_confluence_signal',
104+
'get_momentum_confluence_stats'
100105
]

pyindicators/indicators/__init__.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,10 @@
3636
msb_signal, ob_quality_signal, get_market_structure_stats,
3737
market_structure_choch_bos, choch_bos_signal, get_choch_bos_stats
3838
)
39+
from .momentum_confluence import (
40+
momentum_confluence, momentum_confluence_signal,
41+
get_momentum_confluence_stats
42+
)
3943

4044
__all__ = [
4145
'sma',
@@ -97,5 +101,8 @@
97101
'get_market_structure_stats',
98102
'market_structure_choch_bos',
99103
'choch_bos_signal',
100-
'get_choch_bos_stats'
104+
'get_choch_bos_stats',
105+
'momentum_confluence',
106+
'momentum_confluence_signal',
107+
'get_momentum_confluence_stats'
101108
]

0 commit comments

Comments
 (0)