OPEN-SOURCE SCRIPT
Smoothed Basis

Overview and Purpose
The script calculates a smoothed mid-range basis between the highest and lowest prices over a specified period, then applies a smoothing function (smoothed moving average) to show the trend direction or momentum in a less noisy way. The area between the basis and its smoothed value is color-filled to visually highlight when the basis is above or below the smoothed average, signaling potentially bullish or bearish momentum.
Indicator Setup
length = Period length for calculating the highest and lowest values.
signal = Smoothing period used to smooth the basis.
offset =Optional horizontal shift to the plots (default 0).
Core Calculations
lower = Finds the lowest low over the past length bars.
upper = Finds the highest high over the past length bars.
basis = Calculates the midpoint between the highest and lowest.
Smoothing Calculation (Smoothed Moving Average - SMMA)
Declares smma as 0.0 initially. If the previous smma value is not available (like on the first bar), initializes with a simple moving average of basis over signal bars. Else applies formula
which gives a smoother version of basis which reacts less to sudden changes.
Plotting and Color Fill
Plots the raw basis line and smoothed basis line .
Fills the area between the basis and smoothed basis lines:
Greenish fill if the basis is above the smoothed value (potentially bullish).
Reddish fill if the basis is below the smoothed value (potentially bearish).
Interpretation and Use
The indicator visually shows where price ranges are shifting by tracking the midpoint between recent highs and lows.
The smoothed basis serves as a trend or momentum filter by dampening noise in the basis line.
When the basis is above the smoothed line (green fill), it signals upward momentum or strength; below it (red fill) suggests downward momentum or weakness.
The length and signal parameters allow tuning for different timeframes or asset volatility.
In summary, this code creates a custom smoothed oscillator based on the midpoint range of price extremes, highlighting trend changes via color fills and smoothening price action noise with an SMMA.
The script calculates a smoothed mid-range basis between the highest and lowest prices over a specified period, then applies a smoothing function (smoothed moving average) to show the trend direction or momentum in a less noisy way. The area between the basis and its smoothed value is color-filled to visually highlight when the basis is above or below the smoothed average, signaling potentially bullish or bearish momentum.
Indicator Setup
length = Period length for calculating the highest and lowest values.
signal = Smoothing period used to smooth the basis.
offset =Optional horizontal shift to the plots (default 0).
Core Calculations
lower = Finds the lowest low over the past length bars.
upper = Finds the highest high over the past length bars.
basis = Calculates the midpoint between the highest and lowest.
Smoothing Calculation (Smoothed Moving Average - SMMA)
Declares smma as 0.0 initially. If the previous smma value is not available (like on the first bar), initializes with a simple moving average of basis over signal bars. Else applies formula
which gives a smoother version of basis which reacts less to sudden changes.
Plotting and Color Fill
Plots the raw basis line and smoothed basis line .
Fills the area between the basis and smoothed basis lines:
Greenish fill if the basis is above the smoothed value (potentially bullish).
Reddish fill if the basis is below the smoothed value (potentially bearish).
Interpretation and Use
The indicator visually shows where price ranges are shifting by tracking the midpoint between recent highs and lows.
The smoothed basis serves as a trend or momentum filter by dampening noise in the basis line.
When the basis is above the smoothed line (green fill), it signals upward momentum or strength; below it (red fill) suggests downward momentum or weakness.
The length and signal parameters allow tuning for different timeframes or asset volatility.
In summary, this code creates a custom smoothed oscillator based on the midpoint range of price extremes, highlighting trend changes via color fills and smoothening price action noise with an SMMA.
Script de código abierto
Siguiendo fielmente el espíritu de TradingView, el creador de este script lo ha publicado en código abierto, permitiendo que otros traders puedan revisar y verificar su funcionalidad. ¡Enhorabuena al autor! Puede utilizarlo de forma gratuita, pero tenga en cuenta que la publicación de este código está sujeta a nuestras Normas internas.
Exención de responsabilidad
La información y las publicaciones que ofrecemos, no implican ni constituyen un asesoramiento financiero, ni de inversión, trading o cualquier otro tipo de consejo o recomendación emitida o respaldada por TradingView. Puede obtener información adicional en las Condiciones de uso.
Script de código abierto
Siguiendo fielmente el espíritu de TradingView, el creador de este script lo ha publicado en código abierto, permitiendo que otros traders puedan revisar y verificar su funcionalidad. ¡Enhorabuena al autor! Puede utilizarlo de forma gratuita, pero tenga en cuenta que la publicación de este código está sujeta a nuestras Normas internas.
Exención de responsabilidad
La información y las publicaciones que ofrecemos, no implican ni constituyen un asesoramiento financiero, ni de inversión, trading o cualquier otro tipo de consejo o recomendación emitida o respaldada por TradingView. Puede obtener información adicional en las Condiciones de uso.