OPEN-SOURCE SCRIPT
Updated

SBP Structured Oscillator

385
SBP Structured Oscillator

SBP Structured Oscillator is a composite momentum and market-context oscillator designed to present directional pressure, price displacement, and momentum rotation in a single normalized display.

The purpose of the indicator is not to combine several traditional indicators as separate visual tools. Instead, different measurements are processed together to create one structured oscillator. Each component has a specific role in determining whether price movement is extended, directional pressure is improving or weakening, and the current market environment provides sufficient context for a signal marker.

How the Oscillator Works

The oscillator begins by measuring the distance of price from a smoothed price basis. This distance is normalized by Average True Range (ATR), helping the calculation adapt to instruments with different prices and volatility characteristics.

The normalized displacement is then standardized over a historical lookback period.

A directional composite is added to this displacement measurement. The composite evaluates:

• Price position relative to a smoothed trend basis
• Direction of an adaptive Hull-style weighted average
• ATR-normalized price impulse
• Relative bullish and bearish directional strength
• Changes in directional strength, referred to internally as acceleration

These elements work together because displacement alone can show that price has moved away from its recent equilibrium but does not explain whether directional pressure is strengthening or weakening. The trend and impulse components provide this additional context.

The resulting value is normalized into an oscillator range of approximately -100 to +100.

Adaptive Oscillator Smoothing

The indicator provides three Trading Modes:

SCALPING – uses faster oscillator smoothing and shorter signal spacing.

INTRADAY – applies medium smoothing and spacing for general intraday chart analysis.

SWING – uses stronger smoothing and wider signal spacing to reduce sensitivity to short-term fluctuations.

Volatility is measured relative to its recent ATR average. This volatility relationship is used as a blending weight between faster and smoother oscillator calculations.

The objective is to adjust the oscillator's visual rhythm while maintaining fixed calculation branches suitable for Pine Script execution.

Directional Balance

An adaptive directional-balance calculation compares the position of price within a recent high-low range.

The observation length changes according to a price-efficiency measurement. More directional movement and less efficient movement can therefore produce different observation lengths.

The resulting balance value is used as additional context when evaluating bullish and bearish conditions.

Market Context Filters

Optional context filters are included to reduce signals that occur without sufficient supporting conditions.

Higher-Timeframe Context compares higher-timeframe price with a smoothed higher-timeframe basis.

Structure Context evaluates confirmed pivot progression and recent range expansion.

Directional Context evaluates the current bullish or bearish dominance calculation.

Compressed Regime Filter identifies conditions where both trend separation and ATR are relatively contracted.

These components are intentionally used as contextual filters rather than plotted as separate indicators. Their purpose is to support the oscillator's displacement and rotation logic.

Context Score

The script calculates a deterministic Context Score from directional dominance, directional acceleration, and normalized impulse.

This value is a composite technical score. It is not a statistical probability, prediction, or historical win-rate measurement.

The Minimum Context Score input allows the user to control the amount of directional activity required for primary signal evaluation.

Red and Green Dots

Small dots are plotted directly on the oscillator line to identify filtered changes in oscillator direction.

A green dot marks a change in the smoothed oscillator slope from non-positive to positive.

A red dot marks a change in the smoothed oscillator slope from non-negative to negative.

The dot engine uses mode-dependent smoothing and minimum bar spacing to reduce reactions to minor oscillator fluctuations.

Dots follow an alternating directional sequence so repeated dots of the same colour are suppressed until an opposite directional event occurs.

The dots are analytical rotation markers and should be interpreted together with price structure and the broader chart context.

BUY and SELL Markers

Primary BUY and SELL markers use stricter conditions than the red and green dots.

The oscillator must first reach or recently leave a defined displacement area. Directional rotation, the internally smoothed oscillator trend, selected context conditions, Context Score, and market-regime conditions are then evaluated.

Three Signal Modes are available:

EARLY – uses shallower displacement requirements and less contextual agreement.

BALANCED – provides a middle setting between responsiveness and filtering.

SELECTIVE – requires deeper displacement and greater contextual agreement.

When the Alternate BUY / SELL Sequence option is enabled, repeated primary signals in the same direction are suppressed until an opposite primary signal occurs.

A minimum bar-spacing control is also applied to the primary signal sequence.

Closed-Bar and Higher-Timeframe Handling

When Signals On Closed Bars Only is enabled, signal conditions are evaluated on completed chart bars.

For higher-timeframe context, the script uses completed higher-timeframe values when closed-bar mode is active.

If closed-bar mode is disabled, live higher-timeframe values may change while the higher-timeframe candle is still developing.

Visual Interpretation

The blue oscillator line represents the combined normalized displacement and directional-pressure calculation.

Values above zero generally indicate positive composite pressure, while values below zero generally indicate negative composite pressure.

The optional upper and lower reference bands provide visual displacement references. They should not automatically be interpreted as conventional overbought or oversold levels.

Green and red dots identify filtered oscillator rotations.

BUY and SELL labels identify stronger analytical events where displacement, rotation, and the selected contextual conditions align.

Intended Use

SBP Structured Oscillator is designed as a technical analysis and decision-support tool.

It may be used to study:

• Changes in directional momentum
• Extended price displacement
• Oscillator rotation
• Trend and momentum alignment
• Higher-timeframe context
• Market compression and expansion behaviour

The indicator is not a strategy and does not execute trades.

Signals and markers are generated from deterministic technical conditions based on historical and current chart data. They do not predict future price movement or guarantee a market outcome.

Users should evaluate the indicator together with their own analysis, risk management, and testing process.

Disclaimer

This indicator is provided for educational and analytical purposes only. It does not constitute financial advice, investment advice, or a recommendation to buy or sell any financial instrument.

Trading and investing involve risk. Historical chart behaviour and indicator signals do not guarantee future results.
Release Notes
SBP Structured Oscillator

SBP Structured Oscillator is a composite momentum and market-context oscillator designed to present directional pressure, price displacement, and momentum rotation in a single normalized display.

The purpose of the indicator is not to combine several traditional indicators as separate visual tools. Instead, different measurements are processed together to create one structured oscillator. Each component has a specific role in determining whether price movement is extended, directional pressure is improving or weakening, and the current market environment provides sufficient context for a signal marker.

How the Oscillator Works

The oscillator begins by measuring the distance of price from a smoothed price basis. This distance is normalized by Average True Range (ATR), helping the calculation adapt to instruments with different prices and volatility characteristics.

The normalized displacement is then standardized over a historical lookback period.

A directional composite is added to this displacement measurement. The composite evaluates:

• Price position relative to a smoothed trend basis
• Direction of an adaptive Hull-style weighted average
• ATR-normalized price impulse
• Relative bullish and bearish directional strength
• Changes in directional strength, referred to internally as acceleration

These elements work together because displacement alone can show that price has moved away from its recent equilibrium but does not explain whether directional pressure is strengthening or weakening. The trend and impulse components provide this additional context.

The resulting value is normalized into an oscillator range of approximately -100 to +100.

Adaptive Oscillator Smoothing

The indicator provides three Trading Modes:

SCALPING – uses faster oscillator smoothing and shorter signal spacing.

INTRADAY – applies medium smoothing and spacing for general intraday chart analysis.

SWING – uses stronger smoothing and wider signal spacing to reduce sensitivity to short-term fluctuations.


Directional Balance

An adaptive directional-balance calculation compares the position of price within a recent high-low range.

The observation length changes according to a price-efficiency measurement. More directional movement and less efficient movement can therefore produce different observation lengths.

The resulting balance value is used as additional context when evaluating bullish and bearish conditions.

Market Context Filters

Optional context filters are included to reduce signals that occur without sufficient supporting conditions.

Higher-Timeframe Context compares higher-timeframe price with a smoothed higher-timeframe basis.

Structure Context evaluates confirmed pivot progression and recent range expansion.

Directional Context evaluates the current bullish or bearish dominance calculation.

Compressed Regime Filter identifies conditions where both trend separation and ATR are relatively contracted.

These components are intentionally used as contextual filters rather than plotted as separate indicators. Their purpose is to support the oscillator's displacement and rotation logic.

Context Score

The script calculates a deterministic Context Score from directional dominance, directional acceleration, and normalized impulse.

This value is a composite technical score. It is not a statistical probability, prediction, or historical win-rate measurement.

The Minimum Context Score input allows the user to control the amount of directional activity required for primary signal evaluation.

Red and Green Dots

Small dots are plotted directly on the oscillator line to identify filtered changes in oscillator direction.

A green dot marks a change in the smoothed oscillator slope from non-positive to positive.

A red dot marks a change in the smoothed oscillator slope from non-negative to negative.

The dot engine uses mode-dependent smoothing and minimum bar spacing to reduce reactions to minor oscillator fluctuations.

Dots follow an alternating directional sequence so repeated dots of the same colour are suppressed until an opposite directional event occurs.

The dots are analytical rotation markers and should be interpreted together with price structure and the broader chart context.

BUY and SELL Markers

Primary BUY and SELL markers use stricter conditions than the red and green dots.

The oscillator must first reach or recently leave a defined displacement area. Directional rotation, the internally smoothed oscillator trend, selected context conditions, Context Score, and market-regime conditions are then evaluated.


Visual Interpretation

The blue oscillator line represents the combined normalized displacement and directional-pressure calculation.

Values above zero generally indicate positive composite pressure, while values below zero generally indicate negative composite pressure.

The optional upper and lower reference bands provide visual displacement references. They should not automatically be interpreted as conventional overbought or oversold levels.

Green and red dots identify filtered oscillator rotations.

BUY and SELL labels identify stronger analytical events where displacement, rotation, and the selected contextual conditions align.

Intended Use

SBP Structured Oscillator is designed as a technical analysis and decision-support tool.

It may be used to study:

• Changes in directional momentum
• Extended price displacement
• Oscillator rotation
• Trend and momentum alignment
• Higher-timeframe context
• Market compression and expansion behaviour

The indicator is not a strategy and does not execute trades.

Signals and markers are generated from deterministic technical conditions based on historical and current chart data. They do not predict future price movement or guarantee a market outcome.

Users should evaluate the indicator together with their own analysis, risk management, and testing process.

Disclaimer

This indicator is provided for educational and analytical purposes only. It does not constitute financial advice, investment advice, or a recommendation to buy or sell any financial instrument.

Trading and investing involve risk. Historical chart behaviour and indicator signals do not guarantee future results.
Release Notes
## SBP Structured Oscillator

**SBP Structured Oscillator** is a composite market-analysis tool designed to organize price displacement, trend alignment, volatility-adjusted impulse, directional pressure, and market context into a single structured oscillator.

The purpose of the indicator is to help traders study changes in directional behaviour without relying on a single momentum calculation.

### How the oscillator works

The main blue oscillator combines several related calculations:

• **Normalized Price Displacement** – measures the distance of price from its underlying average and normalizes that movement using ATR and statistical dispersion.

• **Trend Alignment** – evaluates price relative to a smoothed trend basis together with the direction of an adaptive Hull-based calculation.

• **Volatility-Normalized Impulse** – compares recent price movement with current ATR so that impulse is interpreted relative to the instrument's recent volatility.

• **Directional Dominance and Acceleration** – compares bullish and bearish conditions and measures changes in their relative strength.

These components are combined into a bounded oscillator ranging from **-100 to +100**. Mode-adaptive smoothing is applied according to the selected **Scalping, Intraday, or Swing** trading mode.

### Upperline, Midline and Lowerline

The oscillator includes three reference levels:

**Upperline (+80)** – identifies the upper area of the oscillator range.

**Midline (0)** – represents the central balance level of the composite oscillator.

**Lowerline (-80)** – identifies the lower area of the oscillator range.

These are reference levels for interpreting oscillator position and should not be treated as automatic entry or exit levels.

### Red and Green Transition Dots

The red and green dots are generated by a separate **Forward Transition Engine**.

The dot calculation evaluates changes in:

• fast versus slow price impulse
• oscillator acceleration
• candle close-location pressure
• adaptive Hull slope acceleration
• movement relative to the trend basis
• short-term price efficiency
• recent range position

A **green dot** marks a qualified transition toward increasing bullish pressure.

A **red dot** marks a qualified transition toward increasing bearish pressure.

The optional **Next-Move Quality Filter** applies additional continuation checks. These include short-range escape or reclaim behaviour, impulse persistence, available oscillator and range room, adaptive slope behaviour, and an exhaustion filter.

The dots are therefore analytical transition markers. They do not represent guaranteed future price direction and are not intended to identify exact market tops or bottoms.

### BUY and SELL analytical markers

Primary BUY and SELL markers use a different, more selective signal sequence.

The calculation evaluates oscillator extremes and rotation, signal-line direction, directional context, higher-timeframe alignment when enabled, market structure context, rejection behaviour, regime conditions, and the script's deterministic context score.

The **Alternate BUY / SELL Sequence** option can be used to prevent repeated same-direction primary markers until an opposite primary signal occurs.

A configurable cooldown also controls the minimum spacing between primary signals.

### Higher-Timeframe Context

When enabled, the indicator compares higher-timeframe price with a higher-timeframe trend average.

If **Signals On Closed Bars Only** is enabled, completed higher-timeframe values are used for the higher-timeframe context calculation.

This filter is intended to place lower-timeframe oscillator behaviour within a broader directional context.

### Structure and Regime Filters

The structure component evaluates confirmed pivot relationships together with short-range price expansion.

The regime filter compares moving-average separation and ATR behaviour with their recent averages. When enabled, it can suppress signals during comparatively compressed conditions.

These filters are optional and can be enabled or disabled from the indicator settings.

### Context Score

The **Context Score** is a deterministic composite measurement derived from directional dominance, directional acceleration, and volatility-normalized impulse.

It is **not a statistical probability, forecast accuracy percentage, or historical win rate**.

The Minimum Context Score setting allows users to control the amount of composite directional activity required for primary signals.

### Trading Modes

The indicator provides three operating modes:

**SCALPING** – faster oscillator response and shorter signal spacing.

**INTRADAY** – balanced smoothing and signal spacing.

**SWING** – slower oscillator response and wider signal spacing.

The selected mode changes oscillator smoothing and timing characteristics. Users should select a mode appropriate to their chart timeframe, instrument, and analysis style.

### Usage

The SBP Structured Oscillator is intended as a **decision-support and market-analysis indicator**.

Users may study oscillator position, movement around the Midline, directional transitions shown by the dots, and primary analytical markers together with price structure and their own trading methodology.

No signal generated by the indicator guarantees a particular market outcome. Historical chart behaviour does not ensure similar future behaviour.

**Disclaimer:** This indicator is provided for educational and analytical purposes only. It does not constitute investment, trading, or financial advice. Users are responsible for their own analysis, risk management, and trading decisions.
Release Notes
SBP Structured Oscillator is a rule-based analytical indicator that evaluates short-term market structure through a single integrated oscillator. Instead of relying on one technical indicator or combining several unrelated indicators into a simple mashup, it uses one unified calculation in which each analytical component contributes to the final oscillator and transition logic. The objective is to provide a structured view of directional market behaviour while reducing the influence of random price fluctuations and short-lived counter-trend movements.

The oscillator is built around five complementary analytical components that work together throughout the calculation process.

Price-Path Efficiency measures how directly price has travelled over a user-defined lookback period. Strong directional movement generally produces higher efficiency values, while choppy or sideways markets generate lower efficiency values. This helps the oscillator distinguish sustained directional movement from noisy market conditions.

An Adaptive Reference acts as a continuously adjusting equilibrium level instead of using a fixed moving average. Because the reference adapts to changing market conditions, the oscillator can evaluate price behaviour relative to current market dynamics rather than a static baseline.

Directional Pressure measures where price is positioned within an adaptive pressure channel. This helps estimate whether buying or selling pressure is gradually becoming dominant while accounting for changing market volatility.

Normalized Displacement evaluates how far price has moved from the adaptive reference after adjusting for recent volatility. This normalization helps maintain consistent oscillator behaviour across different symbols and market conditions.

Finally, a Directional Persistence process smooths the combined analytical output to reduce insignificant fluctuations while preserving meaningful changes in directional behaviour. The resulting oscillator is designed to respond to genuine shifts in market conditions rather than individual price bars.

The oscillator changes colour only after its internal trend-state engine confirms that directional conditions have meaningfully changed. Instead of reacting to every individual candle, the trend-state engine evaluates multiple pieces of analytical evidence over consecutive confirmed bars before changing the oscillator's directional state. This approach helps reduce unnecessary colour changes during normal pullbacks while maintaining responsiveness when market conditions genuinely transition.

The indicator also plots Bullish Transition and Bearish Transition dots. These markers are generated only after multiple analytical conditions align, including oscillator turning behaviour, directional efficiency, adaptive pressure, recent oscillator extremes, and confirmed bar conditions. An internal alternation process prevents repeated transition markers in the same direction until market conditions have genuinely changed, helping reduce repetitive signals during persistent trends.

Three horizontal reference levels provide additional context for interpreting oscillator behaviour. The upper and lower reference levels help identify extended directional conditions, while the middle reference line represents the equilibrium level around which bullish and bearish directional states develop. These reference levels are intended to assist interpretation rather than generate standalone trading signals.

Features
Unified oscillator architecture built around one analytical workflow
Adaptive market reference that responds to changing market conditions
Price-path efficiency analysis
Adaptive directional pressure measurement
Volatility-normalized displacement analysis
Smoothed trend-state engine
Confirmed Bullish and Bearish Transition markers
Alternating transition logic to reduce repeated directional markers
Clean oscillator interface with minimal visual clutter
Suitable for short-horizon technical analysis
How to use

The oscillator is designed to complement a trader's existing analytical process rather than replace it. Many users may observe the relationship between the oscillator, its reference levels, and confirmed transition markers to evaluate changes in directional conditions. As with any technical indicator, analytical outputs should be considered alongside price action, market structure, volume, volatility, and an appropriate risk-management plan.

Disclaimer

SBP Structured Oscillator is an analytical indicator, not a trading strategy. It does not place trades, generate automated orders, calculate trading performance, guarantee profitable outcomes, or predict future market prices. Its purpose is to provide a structured representation of directional market behaviour that traders can incorporate into their own decision-making process.

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.