Oscillator Profile Indicator


The Oscillator Profile Indicator (OPI) is designed to provide insights into market trends and potential reversal points by profiling the value distribution of an oscillator or the price chart over a specified lookback period.

The OPI works by calculating the Point of Control (PoC) for the oscillator values or prices in the given lookback period. This PoC, essentially a median, is considered the fair value where most trading activities have happened. Along with this, OPI also calculates lower and upper boundaries by taking the specified percentile of the sorted distribution of values. These boundaries outline the value area within which a significant portion of trading activity has occurred.

The main feature of the OPI is the interpretation of PoC movement and how it relates to general market trends. If the PoC moves above 0 on the oscillator, it's a potential indication that we are in a general uptrend. Conversely, if the PoC moves below 0, this can be a signal for a general downtrend.


While OPI can be used on both price charts and oscillators, its effectiveness is more pronounced when used on oscillators. Applying this indicator to oscillators such as the Relative Strength Index (RSI) or the Moving Average Convergence Divergence (MACD) can provide useful insights.

How to Read:

PoC line: The line represents the median of the past 'n' periods. Its movement above or below 0 can be used to identify general uptrends or downtrends respectively.
Upper and Lower Boundary lines: These lines represent the specified percentile of the value distribution in the lookback period.
Colored Fills: The fills between the upper and lower boundary lines visually represent the value area. The color changes based on the relative position of the source value (price or oscillator value) to the PoC.


An uptrend is indicated when the PoC moves above 0 on the oscillator, especially when coupled with an upward crossover of the source value through the PoC.
A downtrend is signaled when the PoC drops below 0 on the oscillator, particularly when paired with a downward crossover of the source value through the PoC.

(!) Note: Like all indicators, OPI should be used in conjunction with other technical analysis tools for the best results. It is also advisable to backtest this indicator with your strategy before using it in live trading.
Release Notes:
Hey everyone, I just rolled out an important update for our Oscillator Profile Indicator to enhance its performance.

The earlier version of my code involved custom percentile and median functions to compute the percentile and median of the oscillator values. This process included sorting the entire series of values, which as you can imagine, is quite demanding computationally and hence, could result in slower execution times.

With this update, I've optimized profiler function by replacing these custom functions with the built-in ta.percentile_linear_interpolation function that TradingView provides. This function allows to directly calculate the percentile of a series, thus eliminating the need for sorting the series first.

This change is crucial as it significantly reduces the computational load of the code and enhances the execution speed. Moreover, using TradingView's native functions also enhances the reliability of all calculations as they're thoroughly tested and optimized for performance.

P.S.. I want to reassure you that this change is solely performance-oriented and does not affect the functionality or output of this script.

Happy trading!
Release Notes:
Hello traders!

I am excited to share an update to this indicator. This update primarily focuses on enhancing the efficiency of profiler function, especially when handling different lookback periods.

What Changed?

Profiler Function Update:
Previously, profiler function used the ta.percentile_linear_interpolation function for all lookback periods. With this update, I introduced a conditional approach:
For lookback periods of 100 or less, we continue using the ta.percentile_linear_interpolation function.
For lookback periods greater than 100, we've shifted to using the ta.percentile_nearest_rank function.

Why This Change?

The rationale behind this modification is twofold:

Optimized Performance: Different percentile functions have different performance characteristics. By choosing the optimal function based on the lookback period, I ensure smoother and faster performance.

Enhanced Accuracy: The ta.percentile_nearest_rank function is better suited for larger datasets, ensuring more accurate percentile calculations for longer lookback periods.

I hope these changes will further improve your experience using the OPI. As always, my primary goal is to provide you with the most efficient and reliable tools for your trading arsenal.

Remember to always backtest any indicator before applying it to your live trading strategy.

Happy trading!
Release Notes:
What's New?

Enhanced Percentile Calculation:
I've updated the logic behind the percentile calculations to better represent actual confidence intervals. Now, when you input a percentile value, the indicator accurately highlights that specific percentage of the area within the given lookback period. This change makes it more intuitive for you to set the desired value area percentile, ensuring that the indicator's output aligns more closely with your expectations.

Float Precision for Percentile Input:
The percentile parameter now accepts float numbers, offering you finer control over the specification of the value area. This enhancement allows for more precise adjustments, enabling you to tailor the indicator's sensitivity to your specific trading strategy.

Improved Point of Control Calculation:
For datasets with an odd number of elements, the Point of Control (PoC) now utilizes the median value, ensuring a more accurate representation of the market's balance point. This adjustment enhances the PoC's reliability as a trend indicator, providing you with a more precise tool for identifying potential market movements.

Open-source script

In true TradingView spirit, the author of this script has published it open-source, so traders can understand and verify it. Cheers to the author! You may use it for free, but reuse of this code in a publication is governed by House Rules. You can favorite it to use it on a chart.


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.

Want to use this script on a chart?