OPEN-SOURCE SCRIPT
3D RSI [UAlgo]

3D RSI is a visual RSI enhancement indicator that transforms the standard RSI line into a dynamic 3D style ribbon inside a separate oscillator pane. Instead of plotting a single line only, the script builds an upper and lower envelope around RSI using a user defined thickness value, then connects and fills those layers bar by bar to create a depth effect. The result is a more expressive RSI display that highlights momentum shifts, overbought and oversold transitions, and local structure in a visually intuitive way.
In addition to the 3D ribbon, the script includes a built in divergence module labeled as 3D Divergence. It detects regular bullish and bearish divergence using RSI pivot highs and lows versus price pivot highs and lows, then draws a bridge style visual in the RSI pane to emphasize the divergence relationship in a depth themed format.
The indicator is designed for traders who want both functionality and presentation. It preserves the standard RSI context through a base RSI plot and common reference levels (70, 50, 30), while adding a layered ribbon, gradient coloring, background zones, live value labeling, and optional divergence annotations.
Educational tool only. Not financial advice.
🔹 Features
🔸 1) 3D RSI Ribbon Visualization
The core feature of the script is a 3D style RSI ribbon built from:
An upper RSI boundary
A lower RSI boundary
A vertical connector on each bar
A filled region between upper and lower boundaries
This creates a depth effect around RSI rather than a flat oscillator line, making momentum expansion and contraction easier to read visually.
🔸 2) User Defined 3D Thickness
The 3D Thickness input controls the distance between the upper and lower ribbon edges around the RSI value. Increasing thickness creates a broader ribbon and a stronger depth effect. Lower values produce a tighter, more precise band around the RSI curve.
🔸 3) Gradient Color Mapping by RSI Level
Ribbon colors are dynamically mapped using a gradient based on RSI value:
Lower RSI values lean toward the Oversold color
Higher RSI values lean toward the Overbought color
This makes the ribbon itself function as a regime heatmap, so you can visually assess oscillator state without reading exact numbers.
🔸 4) Real Time Ribbon Update with Efficient Segment Handling
The script draws new ribbon segments only when a new bar is formed and updates the latest segment while the current bar is still developing. This provides a smooth real time display while controlling object creation and performance.
It also includes cleanup logic that removes older ribbon objects once the stored segment count grows too large.
🔸 5) Built In 3D Divergence Detection (Regular Bullish and Bearish)
When enabled, the indicator detects regular divergence using RSI pivots and price pivots:
Bearish divergence when price makes a higher high while RSI makes a lower high
Bullish divergence when price makes a lower low while RSI makes a higher low
The script uses RSI pivot confirmation with configurable left and right lookback settings, then pairs each new pivot with the most recent prior pivot of the same type.
🔸 6) 3D Divergence Bridge Visualization
Instead of drawing a plain divergence line only, the script creates a bridge style divergence visual in the RSI pane:
An outer edge line (upper for bearish, lower for bullish)
A center line connecting RSI pivot values
Vertical pillar lines at both pivot points
A compact label marking Bull Div or Bear Div
This keeps the divergence presentation consistent with the 3D ribbon concept.
🔸 7) Live RSI Value Label
A dynamic label is placed near the latest RSI point and updates on every bar. The label displays the current RSI value and inherits the same gradient driven color logic as the ribbon, improving readability and quick decision support.
🔸 8) Standard RSI Base Plot Included
The script also plots a classic RSI line in the background with reduced opacity. This is useful for users who want the familiar RSI trace while still benefiting from the 3D ribbon display.
🔸 9) Overbought / Oversold / Mid Reference Levels
The indicator includes standard horizontal reference levels:
70 for overbought
30 for oversold
50 for midpoint
These levels work alongside the ribbon and divergence visuals to preserve standard RSI interpretation workflows.
🔸 10) Background Regime Shading
The script fills the upper (70 to 100) and lower (0 to 30) zones with subtle color shading using the user selected overbought and oversold colors. This helps emphasize extreme zones without overwhelming the pane.
🔸 11) Object Based Internal Design
The script uses custom types for better structure and maintainability:
RSIPoint stores ribbon points (index, RSI, upper, lower)
PivotPoint stores divergence pivots (price and RSI context)
RSI3D stores the engine state, object arrays, labels, and last pivot references
This design supports cleaner extension for future features.
🔹 Calculations
1) RSI Core Calculation
The indicator uses the standard RSI calculation on close:
Pine Script®
A second standard RSI calculation is also plotted as a base line for reference:
Pine Script®
2) 3D Ribbon Geometry (Upper and Lower Layers)
For each valid RSI value, the script builds a 3D envelope using the configured thickness:
Pine Script®
These three values define a single RSIPoint:
The center RSI value
The upper ribbon edge
The lower ribbon edge
The ribbon is then drawn by connecting consecutive RSIPoint objects.
3) RSIPoint History Management
The script stores recent ribbon points in an array. If the current bar already exists as the most recent point, it updates that point. Otherwise it appends a new one:
Pine Script®
History is capped to avoid excessive memory growth:
Pine Script®
4) Ribbon Segment Drawing Logic
When at least two points exist, the script draws or updates a single segment between the previous and current point:
Upper line between previous upper and current upper
Lower line between previous lower and current lower
Vertical line at current bar connecting upper and lower
Filled region between upper and lower lines
Pine Script®
If the bar is still active and no new index exists, the script updates the last segment instead of creating a new one.
5) Gradient Color Calculation for the 3D Ribbon
Ribbon color is derived from the current RSI value using a gradient between the oversold and overbought colors:
Pine Script®
The script then derives related colors from this base for:
Upper line
Lower line
Fill
Vertical connector
This creates a coherent depth style while preserving the RSI level heatmap effect.
6) Live RSI Label Update
The current value label is updated on each draw cycle:
Pine Script®
This keeps the label positioned next to the latest RSI point and colored according to current RSI regime.
7) RSI Pivot Detection for Divergence
The divergence engine uses RSI pivot highs and lows:
Pine Script®
Pivot index is aligned to the true pivot bar by subtracting the right lookback:
Pine Script®
This ensures divergence bridges are anchored to the actual pivot points, not the later confirmation bar.
8) Price and RSI Pivot Pair Construction
When an RSI pivot is confirmed, the script creates a PivotPoint using:
Pivot bar index
Price at pivot bar (high for pivot high, low for pivot low)
RSI pivot value
RSI upper and lower ribbon bounds at the pivot
Examples:
Pine Script®
Pine Script®
9) Bearish Divergence Condition
The script checks regular bearish divergence by comparing the current RSI pivot high to the last stored RSI pivot high:
Pine Script®
Interpretation:
Price prints a higher high
RSI prints a lower high
This is a classic regular bearish divergence condition.
10) Bullish Divergence Condition
The script checks regular bullish divergence by comparing the current RSI pivot low to the last stored RSI pivot low:
Pine Script®
Interpretation:
Price prints a lower low
RSI prints a higher low
This is a classic regular bullish divergence condition.
11) 3D Divergence Bridge Construction
When divergence is detected, the script draws a bridge style annotation in the RSI pane:
Outer edge line uses the RSI upper boundary for bearish divergence or RSI lower boundary for bullish divergence
Center line connects the two RSI pivot values
Vertical pillar lines connect outer edge to center at both pivots
A label is placed near the midpoint reading Bull Div or Bear Div
Key logic:
Pine Script®
This gives divergence signals a depth themed appearance that matches the ribbon.
12) Object Cleanup and Performance Controls
To manage chart object limits, the script trims older ribbon objects when the stored ribbon segment count exceeds a threshold:
Pine Script®
This helps maintain performance while preserving a large recent portion of the 3D ribbon.
13) Reference Levels and Background Zones
The script adds standard RSI reference lines:
Pine Script®
It also shades the upper and lower extreme zones with subtle fills:
Pine Script®
These layers provide familiar RSI context beneath the 3D visuals.
In addition to the 3D ribbon, the script includes a built in divergence module labeled as 3D Divergence. It detects regular bullish and bearish divergence using RSI pivot highs and lows versus price pivot highs and lows, then draws a bridge style visual in the RSI pane to emphasize the divergence relationship in a depth themed format.
The indicator is designed for traders who want both functionality and presentation. It preserves the standard RSI context through a base RSI plot and common reference levels (70, 50, 30), while adding a layered ribbon, gradient coloring, background zones, live value labeling, and optional divergence annotations.
Educational tool only. Not financial advice.
🔹 Features
🔸 1) 3D RSI Ribbon Visualization
The core feature of the script is a 3D style RSI ribbon built from:
An upper RSI boundary
A lower RSI boundary
A vertical connector on each bar
A filled region between upper and lower boundaries
This creates a depth effect around RSI rather than a flat oscillator line, making momentum expansion and contraction easier to read visually.
🔸 2) User Defined 3D Thickness
The 3D Thickness input controls the distance between the upper and lower ribbon edges around the RSI value. Increasing thickness creates a broader ribbon and a stronger depth effect. Lower values produce a tighter, more precise band around the RSI curve.
🔸 3) Gradient Color Mapping by RSI Level
Ribbon colors are dynamically mapped using a gradient based on RSI value:
Lower RSI values lean toward the Oversold color
Higher RSI values lean toward the Overbought color
This makes the ribbon itself function as a regime heatmap, so you can visually assess oscillator state without reading exact numbers.
🔸 4) Real Time Ribbon Update with Efficient Segment Handling
The script draws new ribbon segments only when a new bar is formed and updates the latest segment while the current bar is still developing. This provides a smooth real time display while controlling object creation and performance.
It also includes cleanup logic that removes older ribbon objects once the stored segment count grows too large.
🔸 5) Built In 3D Divergence Detection (Regular Bullish and Bearish)
When enabled, the indicator detects regular divergence using RSI pivots and price pivots:
Bearish divergence when price makes a higher high while RSI makes a lower high
Bullish divergence when price makes a lower low while RSI makes a higher low
The script uses RSI pivot confirmation with configurable left and right lookback settings, then pairs each new pivot with the most recent prior pivot of the same type.
🔸 6) 3D Divergence Bridge Visualization
Instead of drawing a plain divergence line only, the script creates a bridge style divergence visual in the RSI pane:
An outer edge line (upper for bearish, lower for bullish)
A center line connecting RSI pivot values
Vertical pillar lines at both pivot points
A compact label marking Bull Div or Bear Div
This keeps the divergence presentation consistent with the 3D ribbon concept.
🔸 7) Live RSI Value Label
A dynamic label is placed near the latest RSI point and updates on every bar. The label displays the current RSI value and inherits the same gradient driven color logic as the ribbon, improving readability and quick decision support.
🔸 8) Standard RSI Base Plot Included
The script also plots a classic RSI line in the background with reduced opacity. This is useful for users who want the familiar RSI trace while still benefiting from the 3D ribbon display.
🔸 9) Overbought / Oversold / Mid Reference Levels
The indicator includes standard horizontal reference levels:
70 for overbought
30 for oversold
50 for midpoint
These levels work alongside the ribbon and divergence visuals to preserve standard RSI interpretation workflows.
🔸 10) Background Regime Shading
The script fills the upper (70 to 100) and lower (0 to 30) zones with subtle color shading using the user selected overbought and oversold colors. This helps emphasize extreme zones without overwhelming the pane.
🔸 11) Object Based Internal Design
The script uses custom types for better structure and maintainability:
RSIPoint stores ribbon points (index, RSI, upper, lower)
PivotPoint stores divergence pivots (price and RSI context)
RSI3D stores the engine state, object arrays, labels, and last pivot references
This design supports cleaner extension for future features.
🔹 Calculations
1) RSI Core Calculation
The indicator uses the standard RSI calculation on close:
float rsiVal = ta.rsi(src, LEN)
A second standard RSI calculation is also plotted as a base line for reference:
rsiVal = ta.rsi(close, LEN)
plot(rsiVal, "RSI Base", color=color.new(color.gray, 50), linewidth=1)
2) 3D Ribbon Geometry (Upper and Lower Layers)
For each valid RSI value, the script builds a 3D envelope using the configured thickness:
float upperVal = rsiVal + this.thickness
float lowerVal = rsiVal - this.thickness
These three values define a single RSIPoint:
The center RSI value
The upper ribbon edge
The lower ribbon edge
The ribbon is then drawn by connecting consecutive RSIPoint objects.
3) RSIPoint History Management
The script stores recent ribbon points in an array. If the current bar already exists as the most recent point, it updates that point. Otherwise it appends a new one:
if lastPoint.index == bar_index
this.history.set(this.history.size() - 1, newPoint)
else
this.history.push(newPoint)
History is capped to avoid excessive memory growth:
if this.history.size() > 1000
this.history.shift()
4) Ribbon Segment Drawing Logic
When at least two points exist, the script draws or updates a single segment between the previous and current point:
Upper line between previous upper and current upper
Lower line between previous lower and current lower
Vertical line at current bar connecting upper and lower
Filled region between upper and lower lines
line l_up = line.new(p1.index, p1.upper, p2.index, p2.upper, ...)
line l_dn = line.new(p1.index, p1.lower, p2.index, p2.lower, ...)
line l_v = line.new(p2.index, p2.upper, p2.index, p2.lower, ...)
linefill lf = linefill.new(l_up, l_dn, color=colorFill)
If the bar is still active and no new index exists, the script updates the last segment instead of creating a new one.
5) Gradient Color Calculation for the 3D Ribbon
Ribbon color is derived from the current RSI value using a gradient between the oversold and overbought colors:
color c_curr = color.from_gradient(p2.value, 30, 70, COL_OS, COL_OB)
The script then derives related colors from this base for:
Upper line
Lower line
Fill
Vertical connector
This creates a coherent depth style while preserving the RSI level heatmap effect.
6) Live RSI Label Update
The current value label is updated on each draw cycle:
this.current_label.set_xy(p2.index + 1, p2.value)
this.current_label.set_text(str.tostring(p2.value, "#.0"))
this.current_label.set_textcolor(c_curr)
This keeps the label positioned next to the latest RSI point and colored according to current RSI regime.
7) RSI Pivot Detection for Divergence
The divergence engine uses RSI pivot highs and lows:
float ph_rsi_val = ta.pivothigh(rsiVal, DIV_LB, DIV_RB)
float pl_rsi_val = ta.pivotlow(rsiVal, DIV_LB, DIV_RB)
Pivot index is aligned to the true pivot bar by subtracting the right lookback:
int pivot_idx = bar_index - DIV_RB
This ensures divergence bridges are anchored to the actual pivot points, not the later confirmation bar.
8) Price and RSI Pivot Pair Construction
When an RSI pivot is confirmed, the script creates a PivotPoint using:
Pivot bar index
Price at pivot bar (high for pivot high, low for pivot low)
RSI pivot value
RSI upper and lower ribbon bounds at the pivot
Examples:
float ph_price = high[DIV_RB]
PivotPoint curr_ph = PivotPoint.new(pivot_idx, ph_price, ph_rsi_val, ph_upper, ph_lower)
float pl_price = low[DIV_RB]
PivotPoint curr_pl = PivotPoint.new(pivot_idx, pl_price, pl_rsi_val, pl_upper, pl_lower)
9) Bearish Divergence Condition
The script checks regular bearish divergence by comparing the current RSI pivot high to the last stored RSI pivot high:
if curr_ph.price > this.last_ph.price and curr_ph.rsi_val < this.last_ph.rsi_val
draw_bridge(this, this.last_ph, curr_ph, false)
Interpretation:
Price prints a higher high
RSI prints a lower high
This is a classic regular bearish divergence condition.
10) Bullish Divergence Condition
The script checks regular bullish divergence by comparing the current RSI pivot low to the last stored RSI pivot low:
if curr_pl.price < this.last_pl.price and curr_pl.rsi_val > this.last_pl.rsi_val
draw_bridge(this, this.last_pl, curr_pl, true)
Interpretation:
Price prints a lower low
RSI prints a higher low
This is a classic regular bullish divergence condition.
11) 3D Divergence Bridge Construction
When divergence is detected, the script draws a bridge style annotation in the RSI pane:
Outer edge line uses the RSI upper boundary for bearish divergence or RSI lower boundary for bullish divergence
Center line connects the two RSI pivot values
Vertical pillar lines connect outer edge to center at both pivots
A label is placed near the midpoint reading Bull Div or Bear Div
Key logic:
float y1 = is_bullish ? p1.rsi_lower : p1.rsi_upper
float y2 = is_bullish ? p2.rsi_lower : p2.rsi_upper
line.new(p1.index, y1, p2.index, y2, ...)
line.new(p1.index, y1, p1.index, p1.rsi_val, ...)
line.new(p2.index, y2, p2.index, p2.rsi_val, ...)
This gives divergence signals a depth themed appearance that matches the ribbon.
12) Object Cleanup and Performance Controls
To manage chart object limits, the script trims older ribbon objects when the stored ribbon segment count exceeds a threshold:
if this.lines_upper.size() > 480
line.delete(this.lines_upper.shift())
line.delete(this.lines_lower.shift())
line.delete(this.lines_vert.shift())
linefill.delete(this.fills.shift())
This helps maintain performance while preserving a large recent portion of the 3D ribbon.
13) Reference Levels and Background Zones
The script adds standard RSI reference lines:
hline(70, "OB Level", ...)
hline(30, "OS Level", ...)
hline(50, "Mid Level", ...)
It also shades the upper and lower extreme zones with subtle fills:
fill(obLine, plot(100, display=display.none), color=color.new(COL_OB, 95))
fill(osLine, plot(0, display=display.none), color=color.new(COL_OS, 95))
These layers provide familiar RSI context beneath the 3D visuals.
סקריפט קוד פתוח
ברוח האמיתית של TradingView, יוצר הסקריפט הזה הפך אותו לקוד פתוח, כך שסוחרים יוכלו לעיין בו ולאמת את פעולתו. כל הכבוד למחבר! אמנם ניתן להשתמש בו בחינם, אך זכור כי פרסום חוזר של הקוד כפוף ל־כללי הבית שלנו.
Get exclusive indicators: pinescriptmarket.com
All content provided by UAlgo is for informational & educational purposes only. Past performance does not guarantee future results.
All content provided by UAlgo is for informational & educational purposes only. Past performance does not guarantee future results.
כתב ויתור
המידע והפרסומים אינם מיועדים להיות, ואינם מהווים, ייעוץ או המלצה פיננסית, השקעתית, מסחרית או מכל סוג אחר המסופקת או מאושרת על ידי TradingView. קרא עוד ב־תנאי השימוש.
סקריפט קוד פתוח
ברוח האמיתית של TradingView, יוצר הסקריפט הזה הפך אותו לקוד פתוח, כך שסוחרים יוכלו לעיין בו ולאמת את פעולתו. כל הכבוד למחבר! אמנם ניתן להשתמש בו בחינם, אך זכור כי פרסום חוזר של הקוד כפוף ל־כללי הבית שלנו.
Get exclusive indicators: pinescriptmarket.com
All content provided by UAlgo is for informational & educational purposes only. Past performance does not guarantee future results.
All content provided by UAlgo is for informational & educational purposes only. Past performance does not guarantee future results.
כתב ויתור
המידע והפרסומים אינם מיועדים להיות, ואינם מהווים, ייעוץ או המלצה פיננסית, השקעתית, מסחרית או מכל סוג אחר המסופקת או מאושרת על ידי TradingView. קרא עוד ב־תנאי השימוש.