OPEN-SOURCE SCRIPT
Regression Slope Oscillator [BigBeluga]

🔵 OVERVIEW
The Regression Slope Oscillator is a trend–momentum tool that applies multiple linear regression slope calculations over different lookback ranges, then averages them into a single oscillator line. This design helps traders visualize when price is extending beyond typical regression behavior, as well as when momentum is shifting up or down.
🔵 CONCEPTS
🔵 FEATURES
🔵 HOW TO USE
🔵 CONCLUSION
The Regression Slope Oscillator [BigBeluga] transforms raw regression slope data into a smooth, color–coded oscillator. By averaging across multiple regression lengths, it avoids the noise of single–range analysis while still capturing trend extensions and momentum shifts.
With the addition of signal line crossovers and confirmed reversal markers, the indicator now provides both trend context and actionable momentum signals within a single regression-based framework.
The Regression Slope Oscillator is a trend–momentum tool that applies multiple linear regression slope calculations over different lookback ranges, then averages them into a single oscillator line. This design helps traders visualize when price is extending beyond typical regression behavior, as well as when momentum is shifting up or down.
🔵 CONCEPTS
- Regression Slope – Measures the steepness and direction of price trends over a selected length.
Pine Script® f_log_regression(src, length) => float sumX = 0.0 float sumY = 0.0 float sumXSqr = 0.0 float sumXY = 0.0 for i = 0 to length - 1 val = math.log(src) per = i + 1.0 sumX += per sumY += val sumXSqr += per * per sumXY += val * per slope = (length * sumXY - sumX * sumY) / (length * sumXSqr - sumX * sumX) slope*-1 - Multi–Sample Averaging – Instead of relying on one regression slope, the indicator loops through many lengths (from Min Range to Max Range with Step increments) and averages their slopes.
Pine Script® multiSlope(length)=> // Get regression slope slope = f_log_regression(close, length) slopAvg.push(slope) for i = minRange to maxRange by step multiSlope(i) - Color Gradient – The oscillator and candles are colored dynamically from oversold (orange) to overbought (aqua), based on slope extremes observed within the user–defined Color Range.
- Trend Oscillation – When the oscillator rises, price trend is strengthening; when it falls, momentum weakens.
🔵 FEATURES
- Calculates regression slopes across a user–defined range (e.g., 10–100 with steps of 5).
- Averages all sampled slopes into a single oscillator line.
- Dynamic coloring of oscillator and chart candles based on slope values.
- User–controlled Color Range:
High values (e.g., 50–100) → interpret as overbought vs oversold zones.
Low values (e.g., 2–5) → interpret as slope rising vs falling momentum shifts. - Dashboard table (top–right) displaying number of slope samples and current averaged slope value.
- Candle coloring mode (optional) – candles take on the oscillator gradient color for at–a–glance reading of trend bias.
- Signal Line (SMA) – A moving average of the slope oscillator used to identify momentum reversals.
- Bullish Reversal Signal – Triggered when the oscillator crosses above the signal line while below zero, indicating downside momentum exhaustion and potential trend recovery.
- Bearish Reversal Signal – Triggered when the oscillator crosses below the signal line while above zero, indicating upside momentum exhaustion and potential trend rollover.
- Dual Placement Signals – Reversal signals are plotted both:
On the oscillator pane (for momentum context)
On the price chart (for execution alignment)
- Confirmation Logic – Signals are only printed on confirmed bars to reduce repainting and false triggers.
🔵 HOW TO USE
- Watch the oscillator cross above/below zero: signals shifts in regression slope direction.
- Use the signal line crossovers near zero to identify early trend reversals.
- Use high Color Range settings to identify potential overbought/oversold extremes in trend slope.
- Use low Color Range settings for a faster, momentum–driven color change that tracks slope rising/falling.
- Candle coloring highlights short–term trend pressure in sync with the oscillator.
- Combine reversal signals with structure, support/resistance, or volume for higher–probability entries.
🔵 CONCLUSION
The Regression Slope Oscillator [BigBeluga] transforms raw regression slope data into a smooth, color–coded oscillator. By averaging across multiple regression lengths, it avoids the noise of single–range analysis while still capturing trend extensions and momentum shifts.
With the addition of signal line crossovers and confirmed reversal markers, the indicator now provides both trend context and actionable momentum signals within a single regression-based framework.
Open-source script
In true TradingView spirit, the creator of this script has made it open-source, so that traders can review and verify its functionality. Kudos to the author! While you can use it for free, remember that republishing the code is subject to our House Rules.
🔵Gain access to our powerful tools : bigbeluga.com/tv
🔵Join our free discord for updates : bigbeluga.com/discord
All scripts & content provided by BigBeluga are for informational & educational purposes only.
🔵Join our free discord for updates : bigbeluga.com/discord
All scripts & content provided by BigBeluga are for informational & educational purposes only.
Disclaimer
The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.
Open-source script
In true TradingView spirit, the creator of this script has made it open-source, so that traders can review and verify its functionality. Kudos to the author! While you can use it for free, remember that republishing the code is subject to our House Rules.
🔵Gain access to our powerful tools : bigbeluga.com/tv
🔵Join our free discord for updates : bigbeluga.com/discord
All scripts & content provided by BigBeluga are for informational & educational purposes only.
🔵Join our free discord for updates : bigbeluga.com/discord
All scripts & content provided by BigBeluga are for informational & educational purposes only.
Disclaimer
The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.