OPEN-SOURCE SCRIPT

RSI Profile [Kodexius]

120
RSI Profile is an advanced technical indicator that turns the classic RSI into a distribution profile instead of a single oscillating line. Rather than only showing where the RSI is at the current bar, it displays where the RSI has spent most of its time or most of its volume over a user defined lookback period.

The script builds a histogram of RSI values between 0 and 100, splits that range into configurable bins, and then projects the result to the right side of the chart. This gives you a clear visual representation of the RSI structure, including the Point of Control (POC), the Value Area High (VAH), and the Value Area Low (VAL). The POC marks the RSI level with the highest activity, while VAH and VAL bracket the percentage based value area around it.

By combining standard RSI, a distribution profile, and value area logic, this tool lets you study RSI behavior statistically instead of only bar by bar. You can immediately see whether the current RSI reading is located inside the dominant zone, extended above it, or depressed below it, and whether the recent regime has been biased toward overbought, oversold, or neutral territory. This is particularly useful for swing traders, mean reversion systems, and anyone who wants to integrate RSI context into a more profile oriented workflow.

снимок

🔹 Features

1. RSI-Based Distribution Profile

-Builds a histogram of RSI values between 0 and 100.
-The RSI range is divided into a user-defined number of bins (e.g., 30 bins).
-Each bin represents a band of RSI values, such as 0–3.33, 3.33–6.66, ..., 96.66–100.
-For each bar in the lookback period, the script:
-Finds which bin the RSI value belongs to

Adds either:

-1.0 → if using time/frequency
-volume → if using volume-weighted RSI distribution

This creates a clear profile of where RSI has been concentrated over the chosen lookback window.

2. Time / Volume Weighting Mode

Under Profile Settings, you can choose:

-Weight by Volume = false
→ Profile is built using time spent at each RSI level (frequency).
-Weight by Volume = true
→ Profile is built using volume traded at each RSI level.

This flexibility allows you to decide whether you want:

-A pure momentum structure (time spent at each RSI)
-Or a participation-weighted structure (where higher-volume zones are emphasized)

снимок

снимок

3. Configurable Lookback & Resolution

-Profile Lookback: number of historical bars to analyze.

-Number of Bins: controls the resolution of the histogram:
Fewer bins → smoother, fewer gaps
More bins → more detail, but potentially more visual sparsity

-Profile Width (Bars): defines how wide the histogram extends into the future (visually), converted into time using average bar duration.

This provides a balance between performance, clarity, and visual density.

4. Value Area, POC, VAH, VAL

The script computes:

-POC (Point of Control)
→ The RSI bin with the highest total value (time or volume).
-Value Area (VA)
→ The range of RSI bins that contain a user-specified percentage of total activity (e.g., 70%).
-VAH & VAL
→ Upper and lower RSI boundaries of this Value Area.

These are then drawn as horizontal lines and labeled:

-POC line and label
-VAH line and label
-VAL line and label

This gives you a profile-style view similar to classical volume profile, but entirely on the RSI axis.

снимок

5. Color Coding & Visual Design

The histogram bars (boxes) are colored using a smart scheme:

-Below 30 RSI → Oversold zone, uses the Oversold Color (default: green).

-Above 70 RSI → Overbought zone, uses the Overbought Color (default: red).

-Between 30 and 70 RSI → Neutral zone, uses a gradient between:
A soft blue at lower mid levels
A soft orange at higher mid levels

Additional styling:

-POC bin is highlighted in bright yellow.
-Bins inside the Value Area → lower transparency (more solid).
-Bins outside the Value Area → higher transparency (faded).

This makes it easy to visually distinguish:

-Core RSI activity (VA)
-Extremes (oversold/overbought)
-The single dominant zone (POC)

🔹 Calculations

This section summarizes the core logic behind the script and highlights the main building blocks that power the profile.

1. Profile Structure and Bin Initialization

A custom Profile type groups together configuration, bins and drawing objects. During initialization, the script splits the 0 to 100 RSI range into evenly spaced bins, each represented by a Bin record:

Pine Script®
method initBins(Profile p) => p.bins := array.new<Bin>() float step = 100.0 / p.binCount for i = 0 to p.binCount - 1 float low = i * step float high = (i + 1) * step p.bins.push(Bin.new(low, high, 0.0, box(na)))


2. Filling the Profile Over the Lookback Window

On the last bar, the script clears previous drawings and walks backward through the selected lookback window. For each historical bar, it reads the RSI and volume series and feeds them into the profile:

Pine Script®
if barstate.islast myProfile.reset() int start = math.max(0, bar_index - lookback) int end = bar_index for i = 0 to (end - start) float r = rsi float v = volume if not na(r) myProfile.add(r, v)


The add method converts each RSI value into a bin index and accumulates either a frequency count or the bar volume, depending on the chosen mode:

Pine Script®
method add(Profile p, float rsiValue, float volumeValue) => int idx = int(rsiValue / (100.0 / p.binCount)) if idx >= p.binCount idx := p.binCount - 1 if idx < 0 idx := 0 Bin targetBin = p.bins.get(idx) float addedValue = p.useVolume ? volumeValue : 1.0 targetBin.value += addedValue


3. Finding POC and Building the Value Area

Inside the draw method, the script first scans all bins to determine the maximum value and the total sum. The bin with the highest value becomes the POC. The value area is then constructed by expanding from that center bin until the desired percentage of total activity is covered:

Pine Script®
for [i, b] in p.bins totalVal += b.value if b.value > maxVal maxVal := b.value pocIdx := i float vaTarget = totalVal * (p.vaPercent / 100.0) float currentVaVol = maxVal int upIdx = pocIdx int downIdx = pocIdx while currentVaVol < vaTarget float upVol = (upIdx < p.binCount - 1) ? p.bins.get(upIdx + 1).value : 0.0 float downVol = (downIdx > 0) ? p.bins.get(downIdx - 1).value : 0.0 if upVol == 0 and downVol == 0 break if upVol >= downVol upIdx += 1 currentVaVol += upVol else downIdx -= 1 currentVaVol += downVol


Отказ от ответственности

Информация и публикации не предназначены для предоставления и не являются финансовыми, инвестиционными, торговыми или другими видами советов или рекомендаций, предоставленных или одобренных TradingView. Подробнее читайте в Условиях использования.