Momentum divergence pipe
True while momentum rises on the short and medium price changes; despite the name, it does not detect divergence.
It measures the percent change of the close over the last roc_period bars (the short reading) and over twice that (the medium reading). For each reading it keeps the last trend_window values and compares the average of the later half with the earlier half. The output is True when both readings rise, or one rises while the other reading is above zero. It never compares price highs or lows with momentum, so it finds no divergence; it flags momentum that is rising, even while both readings are still negative.
How to read it
- Markers sit on every candle where it is True. At defaults that is about 46% of bars, in runs of roughly six bars, so markers cluster into bursts.
- A marker means momentum has been rising over the last few bars. It does not show that price has turned or that a trend is confirmed.
- A run that starts while the readings are below zero shows momentum recovering from a fall, not price rising.
What it outputs
- Rising momentum
- True when momentum is rising on the short and medium readings, as the summary describes. Drawn on every bar where it is True.
When it fires
When the later-half average beats the earlier-half average on both readings, or on one while the other reading is above zero. It means momentum has been rising over the last trend_window bars, not that price is rising. At defaults that is about 75 runs a day, so one run is not a turning point.
Settings
- roc_period
- Bars each change is measured over; the short reading uses it and the medium uses twice it. Raising it slows both readings and flags only sustained moves. Lowering it reacts to single-bar moves and turns the output on and off more often.
- trend_window
- Recent readings per half-window that get averaged and compared. Raising it looks further back, so runs last longer and change less often. Lowering it reacts faster, but below 4 the first comparison has one reading and the indicator raises ZeroDivisionError.
Pitfalls
- The name suggests price-momentum divergence, but price highs and lows are never read. Momentum can rise while price falls, and it still fires when both readings rise from negative values.
- At defaults it is True on about 46% of bars, so it is seldom quiet. Treat it as a background state and pair it with a trend or level filter.
- trend_window of 1 to 3 raises ZeroDivisionError on its first comparison, when the earlier half is empty. Keep it at 4 or more.