TP RSI v2.0 - Indicator Description

1. TP RSI v2.0 Indicator Description

A 3-in-1 tool for trend, momentum, and volatility analysis

1.1 Indicator Concept

TP RSI v2.0 is built on the three-dimensional integration principle in technical analysis: Trend, Momentum, and Volatility. Instead of switching between multiple indicators, TP RSI brings everything onto a single screen.

The three main theoretical pillars:

  • RSI (Relative Strength Index) – Measures momentum: Based on J. Welles Wilder’s theory, RSI measures the speed and magnitude of price changes to identify when the market is “overbought” or “oversold.” In TP RSI, the RSI line is dynamically colored for instant state recognition.
  • EMA Ribbon – Identifies trend: Uses 10 EMAs from short to long periods (21 to 499), forming 5 “cloud” layers. When short EMAs sit above long EMAs and are green → strong uptrend; red → downtrend. Inspired by Ichimoku Cloud but applied to RSI instead of price.
  • Bollinger Bands on RSI – Gauges volatility: Instead of drawing Bollinger Bands on price, this indicator draws them on RSI to locate “abnormal” momentum zones. When RSI touches or crosses the upper/lower band → strong momentum or potential reversal.

Why combine all three? A single indicator can give false signals. Example: RSI is high (overbought) but if the trend is still strong (green ribbon), you shouldn’t rush to sell. Or when Bollinger Bands tighten → volatility is likely to expand → prepare for a breakout. Combining all three gives traders the “big picture” of the market.

💡 Highlights: Version 2.0 adds Divergence Detection – a powerful tool to catch early trend reversals. When price makes a higher high but RSI makes a lower high (Bear Divergence) → warns the uptrend may be ending.

1.2 Indicator Features

Displayed components and their roles:

  • Dynamically colored RSI line (current_rsi): The main line showing current RSI. Green when RSI is above disp_up → momentum up; red when below disp_down → momentum down; white in between → neutral.
  • 5 EMA Ribbon clouds: Built from 10 EMAs (5 short–long pairs). Each pair forms a “cloud” with different transparency. Colors switch between two styles: “Gradient Fade” (blue gradient for uptrend, red gradient for downtrend) or “Classic” (simple green/red). Role: Shows what phase RSI trend is in – strong, weak, or transitioning.
  • Bollinger Bands (upper1 and lower1): Upper/lower envelopes around RSI. Touching the upper band → very strong momentum (potential short-term overbought); touching the lower band → very weak momentum (potential oversold). Tight bands → “calm” market likely to expand in volatility.
  • Levels 70, 50, 30: Three basic horizontal lines. 70 = classic overbought; 30 = classic oversold; 50 = midpoint.
  • Divergence Labels: When divergence is detected, labels appear on the RSI line:
    • “Bull Div” (green): Regular bullish divergence – price makes a lower low while RSI makes a higher low → bullish reversal signal
    • “Bear Div” (red): Regular bearish divergence – price makes a higher high while RSI makes a lower high → bearish reversal signal
    • “H.Bull Div” (light green): Hidden bullish divergence – confirms the uptrend continuation
    • “H.Bear Div” (light red): Hidden bearish divergence – confirms the downtrend continuation

Alert system (Alerts):

  • RSI Bullish Signal: When RSI crosses above disp_up (momentum turns bullish)
  • RSI Bearish Signal: When RSI drops below disp_down (momentum turns bearish)
  • Bullish/Bearish Divergence: When regular bullish/bearish divergence is detected
  • Hidden Bullish/Bearish Divergence: When hidden divergence is detected
  • RSI Overbought/Oversold: When RSI crosses the 70 or 30 levels

1.3 How to use the indicator in real-world trading

🎯 Strategy 1: Confirm trend before entering

  • Long signal: Green RSI + Ribbon fully green (short EMAs above long EMAs) + RSI above the ribbon → strong uptrend. Wait for RSI to pull back to the ribbon and bounce → safer entry.
  • Short signal: Red RSI + Ribbon fully red + RSI below the ribbon → strong downtrend. Wait for RSI to rally to the ribbon and get rejected → short entry.
  • Avoid trading: When RSI is white (neutral) or sits inside the ribbon (overlapping multi-colored clouds) → unclear market; better to wait.

🎯 Strategy 2: Catch breakouts with Bollinger Bands

  • Bollinger Squeeze: When the distance between upper and lower bands narrows unusually → low volatility, market is “coiling.” Prepare for a strong breakout.
  • Bullish breakout: After a squeeze, if RSI breaks above the upper band + Ribbon turns green → enter Long right after the breakout.
  • Bearish breakout: After a squeeze, if RSI breaks below the lower band + Ribbon turns red → enter Short.
  • Stop Loss: Place SL just below/above the recent squeeze (accumulation) zone or below/above the longest EMA in the ribbon.

🎯 Strategy 3: Divergence trading

  • Bearish divergence: When “Bear Div” appears → price makes a higher high while RSI weakens (lower RSI high). Strong warning that the uptrend is tiring → Prepare to Short when RSI confirms reversal (turns red and breaks the ribbon).
  • Bullish divergence: When “Bull Div” appears → price makes a lower low while RSI strengthens (higher RSI low). Suggests the downtrend may be ending → Prepare to Long when RSI confirms (turns green and clears the ribbon).
  • Hidden divergence: “H.Bull Div” confirms the uptrend remains healthy → consider adding on pullbacks. “H.Bear Div” confirms the downtrend remains strong → consider adding on rallies.

🎯 Strategy 4: Risk management and take-profit

  • TP by 70/30 levels: If Long and RSI hits 70 (overbought) + starts turning white or red → consider partial take-profit or a trailing stop. Similarly for Shorts at 30.
  • Trailing stop with the Ribbon: After entry, use the longest EMA (or the whole ribbon) as “dynamic support” for Longs and “dynamic resistance” for Shorts. If RSI breaks the ribbon against your trade → exit immediately.
  • Confirm with alerts: Enable key alerts like “RSI Bullish/Bearish Signal” and “Divergence” so you don’t miss setups when away from charts.
⚠️ Important note: Don’t rely on a single factor. The best signals are when all three align: RSI has a clear color (green/red) + Ribbon matches + Bollinger Bands confirm (either a breakout or a reasonable zone). Avoid trading when RSI is white or tangled inside the ribbon.

1.4 How the indicator works

📥 Inputs and their roles:

  • Price source (Source)src = close: The closing price of each bar. This is the base data for RSI. You can switch to open, high, low, or hlc3 to experiment.
  • RSI Periodfor_rsi = 50: Number of bars used to compute RSI. Default 50 (balanced). Smaller → more sensitive to short-term moves; larger → smoother, less noise.
  • Bollinger Bands Periodfor_ma = 50: Bars used to compute the RSI basis of Bollinger Bands.
  • BB Multiplierfor_mult = 1.0: Band width relative to standard deviation. Larger → wider bands → fewer touches; smaller → narrower bands → more touches.
  • 10 EMA lengths for the Ribbonma_len1 to ma_len10: From 21, 48, 51... up to 499. These form 5 short–long EMA pairs; each pair forms one cloud. EMAs are computed on RSI (not price).
  • MA Typematype = 'EMA': Choose EMA, SMA, WMA, HMA, RMA, or ALMA. Each has different characteristics (EMA faster, SMA smoother, HMA reduces lag, etc.).
  • Divergence settings:
    • i_pivot_lookback = 5: Bars to the left and right to define an RSI pivot (high/low). Larger → fewer but stronger pivots.
    • i_max_lookback = 60: Maximum bar distance between two pivots to compare divergence. If too far apart → no divergence.

⚙️ Main logic blocks and roles:

  • Logic 1: Compute base RSI
    • current_rsi = ta.rsi(src, for_rsi): Uses Pine Script’s standard RSI. It calculates the ratio of average gains to average losses over the last for_rsi bars, then maps to 0–100.
    • Role: Provides the raw RSI value for downstream logic.
  • Logic 2: Build Bollinger Bands on RSI
    • basis = ta.ema(current_rsi, for_ma): The moving average of RSI.
    • dev = for_mult * ta.stdev(current_rsi, for_ma): RSI standard deviation multiplied by for_mult.
    • upper = basis + dev and lower = basis - dev: Upper and lower bands.
    • disp_up = basis + (upper - lower) * for_sigma and disp_down = basis - (upper - lower) * for_sigma: Two dynamic thresholds to mark when RSI “breaks up” (green) or “falls down” (red). for_sigma = 0.1 creates a small buffer to avoid over-sensitive color flipping.
    • Role: Builds a dynamic volatility zone for RSI to detect abnormal momentum and color the RSI line.
  • Logic 3: Decide RSI color
    • color_rsi = current_rsi >= disp_up ? i_bull_color : current_rsi <= disp_down ? i_bear_color : i_neutral_color
    • If RSI ≥ disp_up → green (bullish); if RSI ≤ disp_down → red (bearish); otherwise → white (neutral).
    • Role: Let traders read momentum state at a glance via color instead of numbers.
  • Logic 4: Compute the EMA Ribbon system
    • Function f_ma(malen): Computes MA types (EMA, SMA, WMA, HMA, RMA, ALMA) per user choice.
    • 10 MAs are computed: mashort1 = f_ma(ma_len1), malong1 = f_ma(ma_len2)... up to mashort5, malong5.
    • Function f_get_ribbon_colors(): Sets each ribbon layer’s color based on short-over-long or short-under-long EMA. Two styles: “Gradient Fade” (5 gradient shades of green/red) or “Classic” (single green/red).
    • Role: Creates colored “cloud” layers to clarify the RSI trend. All green → strong uptrend; all red → strong downtrend; mixed → ranging.
  • Logic 5: Detect RSI pivot points (highs/lows)
    • ph = ta.pivothigh(current_rsi, i_pivot_lookback, i_pivot_lookback): Finds RSI highs. A valid high is higher than the previous and next i_pivot_lookback bars.
    • pl = ta.pivotlow(current_rsi, i_pivot_lookback, i_pivot_lookback): Finds RSI lows. A valid low is lower than the previous and next i_pivot_lookback bars.
    • Similarly, ph_price and pl_price store price pivots (high/low) to compare with RSI pivots.
    • These pivots are stored in arrays: rsi_highs, rsi_lows, price_highs, price_lows along with their bar_index.
    • Role: Identify key RSI and price turning points to form the basis for divergence checks.
  • Logic 6: Divergence Detection
    • Function f_check_divergence() compares the two latest pivots:
      • Regular Bullish: If price makes a lower low (curr_price_low < prev_price_low) while RSI makes a higher low (curr_rsi_low > prev_rsi_low) → bull_regular = true.
      • Regular Bearish: If price makes a higher high (curr_price_high > prev_price_high) while RSI makes a lower high (curr_rsi_high < prev_rsi_high) → bear_regular = true.
      • Hidden Bullish: Price makes a higher low while RSI makes a lower low.
      • Hidden Bearish: Price makes a lower high while RSI makes a higher high.
    • Conditions: Two pivots must be within i_max_lookback bars and at least i_pivot_lookback bars apart.
    • Role: Catch early reversal signals or confirm trend continuation, giving traders a time advantage.

📤 Outputs and display:

  • Colored RSI line: Drawn with plot(current_rsi, color=color_rsi, linewidth=1). Color follows the logic above.
  • 10 EMAs and 5 filled layers (ribbon clouds): plot(mashort1, ...) through plot(malong5, ...). Use fill() between short and long EMAs to create “clouds.” Each layer’s transparency varies (from i_cloud_transparency - 10 to i_cloud_transparency + 10) to add depth.
  • Two Bollinger Bands: plot(upper1, ...) and plot(lower1, ...) with light purple/blue colors and high transparency (70%).
  • Three horizontal lines: hline(70, ...), hline(50, ...), hline(30, ...) to mark overbought/oversold zones.
  • Divergence labels: label.new(bar_index, current_rsi, "Bull\nDiv", ...) appears when divergence is detected. Green for bull, red for bear, with transparency for hidden divergence.
💡 Example of the processing flow:
Assume: BTC price is $50,000. Over the last 50 bars, price rose from $48,000 to $50,000.
Step 1 (Input): Take the 50 most recent closes: [48000, 48200, 48500, ... , 49800, 50000].
Step 2 (RSI logic): ta.rsi(close, 50) computes: Avg gain = 40 points/bar; Avg loss = 10 points/bar → RS = 40/10 = 4 → RSI = 100 − 100/(1+4) = 80.
Step 3 (Bollinger logic): EMA of RSI = 75; stdev = 5 → upper = 75 + 5 = 80, lower = 75 − 5 = 70. Current RSI (80) touches the upper band → very strong momentum.
Step 4 (Color logic): disp_up = 75 + (80−70)*0.1 = 76. RSI = 80 > 76 → green (strong bullish).
Step 5 (Ribbon logic): RSI EMA21 = 78, EMA48 = 75. EMA21 > EMA48 → first cloud is green. Similarly for others → entire ribbon green.
Step 6 (Pivot & Divergence): Find pivot: 5 bars back RSI = [72, 74, 76, 78, 80], 5 bars forward suppose RSI drops to [79, 77, 75, 73, 71] → current bar (RSI=80) is a pivot high. Compare with prior pivot high (say RSI=82 at $49,500): Price rises ($50,000 > $49,500) but RSI falls (80 < 82) → Bearish divergence → “Bear Div” label appears.
Step 7 (Output): Show a green RSI at 80, all-green ribbon, Bollinger upper band touched, and a “Bear Div” label → Warning: Momentum is strong but showing exhaustion (divergence), so watch for a reversal.
Zoom/Pan Layered Image
Background Overlay
+

Use the analysis above + the code below to instruct AI to modify the indicator and turn it into a trading bot—no coding required!

How to do it here -> 👉ZERO2HERO👈

				
					// This Pine Script® code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © TrendlineProject
// Last update: October 2024 - v2.0: Fixed MA bug, added divergences, enhanced visuals, alert system

//@version=5
indicator('TP RSI v2.0', overlay=false)

// === RSI SETTINGS ===
i_rsi_group = "═══════ RSI Settings ═══════"
src = input(close, 'Source', group=i_rsi_group)
for_rsi = input.int(50, 'RSI Period', minval=2, group=i_rsi_group)
for_ma = input.int(50, 'BB Period', minval=2, group=i_rsi_group)
for_mult = input.float(1.0, 'BB Band', minval=0.1, step=0.1, group=i_rsi_group)

// === RIBBON SETTINGS ===
i_ribbon_group = "═══════ Ribbon Settings ═══════"
matype = input.string('EMA', 'MA Type', options=['EMA', 'SMA', 'WMA', 'HMA', 'RMA', 'ALMA'], group=i_ribbon_group)

ma_len1 = input.int(21, "Short EMA1 Length", group=i_ribbon_group)
ma_len2 = input.int(48, "Long EMA1 Length", group=i_ribbon_group)
ma_len3 = input.int(51, "Short EMA2 Length", group=i_ribbon_group)
ma_len4 = input.int(98, "Long EMA2 Length", group=i_ribbon_group)
ma_len5 = input.int(103, "Short EMA3 Length", group=i_ribbon_group)
ma_len6 = input.int(149, "Long EMA3 Length", group=i_ribbon_group)
ma_len7 = input.int(155, "Short EMA4 Length", group=i_ribbon_group)
ma_len8 = input.int(199, "Long EMA4 Length", group=i_ribbon_group)
ma_len9 = input.int(206, "Short EMA5 Length", group=i_ribbon_group)
ma_len10 = input.int(499, "Long EMA5 Length", group=i_ribbon_group)

showLine = input.bool(false, "Display EMA Lines", group=i_ribbon_group)

// === DIVERGENCE SETTINGS ===
i_div_group = "═══════ Divergence Settings ═══════"
i_show_divergence = input.bool(true, "Show Divergences", group=i_div_group)
i_show_regular = input.bool(true, "Show Regular Divergence", group=i_div_group)
i_show_hidden = input.bool(true, "Show Hidden Divergence", group=i_div_group)
i_pivot_lookback = input.int(5, "Pivot Lookback", minval=1, maxval=20, group=i_div_group)
i_max_lookback = input.int(60, "Max Lookback Range", minval=10, maxval=200, group=i_div_group)

// === STYLE SETTINGS ===
i_style_group = "═══════ Style Settings ═══════"
i_ribbon_style = input.string("Gradient Fade", "Ribbon Color Style", options=["Gradient Fade", "Classic"], group=i_style_group)
i_cloud_transparency = input.int(40, "Cloud Transparency", minval=20, maxval=90, step=5, group=i_style_group)
i_show_bb = input.bool(true, "Show Bollinger Bands", group=i_style_group)
i_show_ob_os = input.bool(true, "Show Overbought/Oversold Levels", group=i_style_group)

// Custom colors
i_bull_color = input.color(#5b9cf6, "Bullish RSI Color", group=i_style_group)
i_bear_color = input.color(#f7525f, "Bearish RSI Color", group=i_style_group)
i_neutral_color = input.color(#fdfdfd, "Neutral RSI Color", group=i_style_group)

// === CALCULATIONS ===
for_sigma = 0.1
current_rsi = ta.rsi(src, for_rsi)
basis = ta.ema(current_rsi, for_ma)
dev = for_mult * ta.stdev(current_rsi, for_ma)
upper = basis + dev
lower = basis - dev
disp_up = basis + (upper - lower) * for_sigma
disp_down = basis - (upper - lower) * for_sigma

// RSI color logic
color_rsi = current_rsi >= disp_up ? i_bull_color : current_rsi <= disp_down ? i_bear_color : i_neutral_color
rsi_Green = ta.crossover(current_rsi, disp_up)
rsi_Red = ta.crossunder(current_rsi, disp_down)

// === MA FUNCTION (FIXED) ===
f_alma(src_alma, length, offset, sigma) =>
    m = math.floor(offset * (length - 1))
    s = length / sigma
    norm = 0.0
    sum = 0.0
    for i = 0 to length - 1
        weight = math.exp(-1 * math.pow(i - m, 2) / (2 * math.pow(s, 2)))
        norm := norm + weight
        sum := sum + src_alma[length - 1 - i] * weight
    sum / norm

f_ma(malen) =>
    float result = na
    if matype == 'EMA'
        result := ta.ema(current_rsi, malen)
    else if matype == 'SMA'
        result := ta.sma(current_rsi, malen)
    else if matype == 'WMA'
        result := ta.wma(current_rsi, malen)
    else if matype == 'HMA'
        result := ta.hma(current_rsi, malen)
    else if matype == 'RMA'
        result := ta.rma(current_rsi, malen)
    else if matype == 'ALMA'
        result := f_alma(current_rsi, malen, 0.85, 6)
    result

// Calculate MAs
mashort1 = f_ma(ma_len1)
malong1 = f_ma(ma_len2)
mashort2 = f_ma(ma_len3)
malong2 = f_ma(ma_len4)
mashort3 = f_ma(ma_len5)
malong3 = f_ma(ma_len6)
mashort4 = f_ma(ma_len7)
malong4 = f_ma(ma_len8)
mashort5 = f_ma(ma_len9)
malong5 = f_ma(ma_len10)

// === RIBBON COLORS (QUANTUM STYLE) ===
f_get_ribbon_colors(style, is_bullish, layer) =>
    if style == "Gradient Fade"
        bull_colors = array.from(#00d4ff, #00b8e6, #0099cc, #007fb3, #006699)
        bear_colors = array.from(#ff0066, #e6005c, #cc0052, #b30047, #99003d)
        is_bullish ? array.get(bull_colors, layer - 1) : array.get(bear_colors, layer - 1)
    else
        is_bullish ? #026a9e : #8d3e68

cloudcolour1 = f_get_ribbon_colors(i_ribbon_style, mashort1 >= malong1, 1)
cloudcolour2 = f_get_ribbon_colors(i_ribbon_style, mashort2 >= malong2, 2)
cloudcolour3 = f_get_ribbon_colors(i_ribbon_style, mashort3 >= malong3, 3)
cloudcolour4 = f_get_ribbon_colors(i_ribbon_style, mashort4 >= malong4, 4)
cloudcolour5 = f_get_ribbon_colors(i_ribbon_style, mashort5 >= malong5, 5)

mashortcolor1 = f_get_ribbon_colors(i_ribbon_style, mashort1 >= mashort1[1], 1)
mashortcolor2 = f_get_ribbon_colors(i_ribbon_style, mashort2 >= mashort2[1], 2)
mashortcolor3 = f_get_ribbon_colors(i_ribbon_style, mashort3 >= mashort3[1], 3)
mashortcolor4 = f_get_ribbon_colors(i_ribbon_style, mashort4 >= mashort4[1], 4)
mashortcolor5 = f_get_ribbon_colors(i_ribbon_style, mashort5 >= mashort5[1], 5)

malongcolor1 = f_get_ribbon_colors(i_ribbon_style, malong1 >= malong1[1], 1)
malongcolor2 = f_get_ribbon_colors(i_ribbon_style, malong2 >= malong2[1], 2)
malongcolor3 = f_get_ribbon_colors(i_ribbon_style, malong3 >= malong3[1], 3)
malongcolor4 = f_get_ribbon_colors(i_ribbon_style, malong4 >= malong4[1], 4)
malongcolor5 = f_get_ribbon_colors(i_ribbon_style, malong5 >= malong5[1], 5)

// === DIVERGENCE DETECTION ===
ph = ta.pivothigh(current_rsi, i_pivot_lookback, i_pivot_lookback)
pl = ta.pivotlow(current_rsi, i_pivot_lookback, i_pivot_lookback)

ph_price = ta.pivothigh(high, i_pivot_lookback, i_pivot_lookback)
pl_price = ta.pivotlow(low, i_pivot_lookback, i_pivot_lookback)

// Store pivot points
var float[] rsi_highs = array.new_float(0)
var int[] rsi_high_bars = array.new_int(0)
var float[] rsi_lows = array.new_float(0)
var int[] rsi_low_bars = array.new_int(0)

var float[] price_highs = array.new_float(0)
var int[] price_high_bars = array.new_int(0)
var float[] price_lows = array.new_float(0)
var int[] price_low_bars = array.new_int(0)

// Store RSI pivots
if not na(ph)
    array.unshift(rsi_highs, ph)
    array.unshift(rsi_high_bars, bar_index - i_pivot_lookback)
    if array.size(rsi_highs) > 10
        array.pop(rsi_highs)
        array.pop(rsi_high_bars)

if not na(pl)
    array.unshift(rsi_lows, pl)
    array.unshift(rsi_low_bars, bar_index - i_pivot_lookback)
    if array.size(rsi_lows) > 10
        array.pop(rsi_lows)
        array.pop(rsi_low_bars)

// Store price pivots
if not na(ph_price)
    array.unshift(price_highs, ph_price)
    array.unshift(price_high_bars, bar_index - i_pivot_lookback)
    if array.size(price_highs) > 10
        array.pop(price_highs)
        array.pop(price_high_bars)

if not na(pl_price)
    array.unshift(price_lows, pl_price)
    array.unshift(price_low_bars, bar_index - i_pivot_lookback)
    if array.size(price_lows) > 10
        array.pop(price_lows)
        array.pop(price_low_bars)

// Divergence detection function
f_check_divergence() =>
    bool bull_regular = false
    bool bear_regular = false
    bool bull_hidden = false
    bool bear_hidden = false
    
    // Only check on new pivot formation
    is_new_low = not na(pl)
    is_new_high = not na(ph)
    
    // Bullish Regular: Price LL, RSI HL
    if is_new_low and array.size(rsi_lows) >= 2 and array.size(price_lows) >= 2
        curr_rsi_low = array.get(rsi_lows, 0)
        prev_rsi_low = array.get(rsi_lows, 1)
        curr_price_low = array.get(price_lows, 0)
        prev_price_low = array.get(price_lows, 1)
        
        curr_bar = array.get(rsi_low_bars, 0)
        prev_bar = array.get(rsi_low_bars, 1)
        
        if (bar_index - prev_bar) <= i_max_lookback and (bar_index - prev_bar) > i_pivot_lookback
            if curr_price_low < prev_price_low and curr_rsi_low > prev_rsi_low
                bull_regular := true
    
    // Bearish Regular: Price HH, RSI LH
    if is_new_high and array.size(rsi_highs) >= 2 and array.size(price_highs) >= 2
        curr_rsi_high = array.get(rsi_highs, 0)
        prev_rsi_high = array.get(rsi_highs, 1)
        curr_price_high = array.get(price_highs, 0)
        prev_price_high = array.get(price_highs, 1)
        
        curr_bar = array.get(rsi_high_bars, 0)
        prev_bar = array.get(rsi_high_bars, 1)
        
        if (bar_index - prev_bar) <= i_max_lookback and (bar_index - prev_bar) > i_pivot_lookback
            if curr_price_high > prev_price_high and curr_rsi_high < prev_rsi_high
                bear_regular := true
    
    // Bullish Hidden: Price HL, RSI LL
    if is_new_low and array.size(rsi_lows) >= 2 and array.size(price_lows) >= 2
        curr_rsi_low = array.get(rsi_lows, 0)
        prev_rsi_low = array.get(rsi_lows, 1)
        curr_price_low = array.get(price_lows, 0)
        prev_price_low = array.get(price_lows, 1)
        
        curr_bar = array.get(rsi_low_bars, 0)
        prev_bar = array.get(rsi_low_bars, 1)
        
        if (bar_index - prev_bar) <= i_max_lookback and (bar_index - prev_bar) > i_pivot_lookback
            if curr_price_low > prev_price_low and curr_rsi_low < prev_rsi_low
                bull_hidden := true
    
    // Bearish Hidden: Price LH, RSI HH
    if is_new_high and array.size(rsi_highs) >= 2 and array.size(price_highs) >= 2
        curr_rsi_high = array.get(rsi_highs, 0)
        prev_rsi_high = array.get(rsi_highs, 1)
        curr_price_high = array.get(price_highs, 0)
        prev_price_high = array.get(price_highs, 1)
        
        curr_bar = array.get(rsi_high_bars, 0)
        prev_bar = array.get(rsi_high_bars, 1)
        
        if (bar_index - prev_bar) <= i_max_lookback and (bar_index - prev_bar) > i_pivot_lookback
            if curr_price_high < prev_price_high and curr_rsi_high > prev_rsi_high
                bear_hidden := true
    
    [bull_regular, bear_regular, bull_hidden, bear_hidden]

[div_bull_reg, div_bear_reg, div_bull_hid, div_bear_hid] = f_check_divergence()

// Display divergences
if i_show_divergence and i_show_regular and div_bull_reg
    label.new(bar_index, current_rsi, "Bull\nDiv", style=label.style_label_up, color=color.new(color.green, 0), textcolor=color.white, size=size.small)

if i_show_divergence and i_show_regular and div_bear_reg
    label.new(bar_index, current_rsi, "Bear\nDiv", style=label.style_label_down, color=color.new(color.red, 0), textcolor=color.white, size=size.small)

if i_show_divergence and i_show_hidden and div_bull_hid
    label.new(bar_index, current_rsi, "H.Bull\nDiv", style=label.style_label_up, color=color.new(color.green, 50), textcolor=color.white, size=size.small)

if i_show_divergence and i_show_hidden and div_bear_hid
    label.new(bar_index, current_rsi, "H.Bear\nDiv", style=label.style_label_down, color=color.new(color.red, 50), textcolor=color.white, size=size.small)

// === VISUALIZATION ===
// RSI line
plot(current_rsi, color=color_rsi, linewidth=1, title="RSI")

// Ribbon
mashortline1 = plot(mashort1, color=showLine ? color.new(mashortcolor1, 0) : na, linewidth=1, title="Short EMA1")
mashortline2 = plot(mashort2, color=showLine ? color.new(mashortcolor2, 0) : na, linewidth=1, title="Short EMA2")
mashortline3 = plot(mashort3, color=showLine ? color.new(mashortcolor3, 0) : na, linewidth=1, title="Short EMA3")
mashortline4 = plot(mashort4, color=showLine ? color.new(mashortcolor4, 0) : na, linewidth=1, title="Short EMA4")
mashortline5 = plot(mashort5, color=showLine ? color.new(mashortcolor5, 0) : na, linewidth=1, title="Short EMA5")

malongline1 = plot(malong1, color=showLine ? color.new(malongcolor1, 0) : na, linewidth=3, title="Long EMA1")
malongline2 = plot(malong2, color=showLine ? color.new(malongcolor2, 0) : na, linewidth=3, title="Long EMA2")
malongline3 = plot(malong3, color=showLine ? color.new(malongcolor3, 0) : na, linewidth=3, title="Long EMA3")
malongline4 = plot(malong4, color=showLine ? color.new(malongcolor4, 0) : na, linewidth=3, title="Long EMA4")
malongline5 = plot(malong5, color=showLine ? color.new(malongcolor5, 0) : na, linewidth=3, title="Long EMA5")

fill(mashortline1, malongline1, color=color.new(cloudcolour1, i_cloud_transparency - 10), title="Cloud1")
fill(mashortline2, malongline2, color=color.new(cloudcolour2, i_cloud_transparency - 5), title="Cloud2")
fill(mashortline3, malongline3, color=color.new(cloudcolour3, i_cloud_transparency), title="Cloud3")
fill(mashortline4, malongline4, color=color.new(cloudcolour4, i_cloud_transparency + 5), title="Cloud4")
fill(mashortline5, malongline5, color=color.new(cloudcolour5, i_cloud_transparency + 10), title="Cloud5")

// Bollinger Bands
length = input.int(50, 'BB Period', group='BB Settings')
mult = input.float(2.0, 'BB Band', group='BB Settings')
basi = ta.sma(current_rsi, length)
dev1 = mult * ta.stdev(current_rsi, length)
upper1 = basi + dev1
lower1 = basi - dev1

p1 = plot(i_show_bb ? upper1 : na, "Upper BB", color=color.new(#ec40f9, 70), linewidth=1)
p2 = plot(i_show_bb ? lower1 : na, "Lower BB", color=color.new(#3179f5, 70), linewidth=1)

// OB/OS levels (Quantum style)
h1 = hline(i_show_ob_os ? 70 : na, color=color.new(color.red, 70), linewidth=1, linestyle=hline.style_dotted, title="Overbought")
h2 = hline(i_show_ob_os ? 30 : na, color=color.new(color.green, 70), linewidth=1, linestyle=hline.style_dotted, title="Oversold")
hline(50, color=color.new(color.gray, 80), linewidth=1, linestyle=hline.style_solid, title="Midline")

// === ALERTS ===
alertcondition(rsi_Green, "RSI Bullish Signal", "TP RSI: RSI crossed above upper threshold")
alertcondition(rsi_Red, "RSI Bearish Signal", "TP RSI: RSI crossed below lower threshold")

alertcondition(div_bull_reg, "Bullish Divergence", "TP RSI: Regular bullish divergence detected")
alertcondition(div_bear_reg, "Bearish Divergence", "TP RSI: Regular bearish divergence detected")

alertcondition(div_bull_hid, "Hidden Bullish Divergence", "TP RSI: Hidden bullish divergence detected")
alertcondition(div_bear_hid, "Hidden Bearish Divergence", "TP RSI: Hidden bearish divergence detected")

alertcondition(ta.cross(current_rsi, 70), "RSI Overbought", "TP RSI: RSI crossed overbought level (70)")
alertcondition(ta.cross(current_rsi, 30), "RSI Oversold", "TP RSI: RSI crossed oversold level (30)")
				
			

Other Indicators

04/02/026 Cup & Handle

Isolated Scroll Container 1. Cup & Handle Indicator Description (Zeiierman) An indicator that automatically detects the Cup & Handle pattern – one of the most classic chart patterns in technical analysis 1.1 Indicator Concept The Cup & Handle indicator is based on the theory of market psychology patterns discovered by

27/01/026 Spring & Upthrust Trap

Backtest analysis of Spring & Upthrust Trap strategy: 34.9% win rate, +4.95% profit, 2.021 profit factor. Complete guide to optimal settings and risk management.

Smart Money Concepts Pro – OB, FVG, Liquidity + Trade Setups 

The indicator follows Smart Money Concepts (SMC): price moves because of supply–demand imbalances and the hunt for liquidity. From there, we focus on four key pillars:

Order Block (OB): institutional order zones; price often retests them before continuing.
Fair Value Gap (FVG): a 3-candle void showing imbalance; price tends