在脚本中搜索"rsi"
RSI with Bollinger Bands [Erionis]RSI + Bollinger Bands. Usefull to see possible reversal points. Use it accordingly.
rsi with bb [or]rsi has 2 line. 30 and 70.
but we can use BB instead of that.
i dont know it is good idea or not.
cause i rarely use rsi.
anyway if you are interested in it, you can try :)
enjoy and earn money.
RSI in Bull and Bear Market V2.0RSI oversold at 60/40 in bullish market
And Overbought at 40/60 in Bearish market
 for more info of this Strategy 
RSI+The Relative Strength Index can be used to determine Overbought and Oversold market conditions. This RSI+ indicator is set to a length faster then normal and changes color depending on momentum. When the RSI is Overbought a red shadow appears to indicate a sell is setting up. When the RSI is Oversold a green shadow appears to indicate a buy is setting up
RSI-VA modified RSI script with a a slight modified net volume formula 
red is bearish 
green is bullish 
just attempt to make the RSI more easy and better to use
best entry is when green bellow 30 
and vice versa when red start to cross down the 70 
RSIStandard RSI that uses the highest and lowest output plots of the RSI formula using open, high, low, close formulas.
RSI Full Forecast [Titans_Invest]RSI Full Forecast  
Get ready to experience the ultimate evolution of RSI-based indicators – the RSI Full Forecast, a boosted and even smarter version of the already powerful:  RSI Forecast  
Now featuring over 40 additional entry conditions (forecasts), this indicator redefines the way you view the market.
AI-Powered RSI Forecasting:
Using advanced linear regression with the least squares method – a solid foundation for machine learning - the RSI Full Forecast enables you to predict future RSI behavior with impressive accuracy.
But that’s not all: this new version also lets you monitor future crossovers between the RSI and the MA RSI, delivering early and strategic signals that go far beyond traditional analysis.
You’ll be able to monitor future crossovers up to 20 bars ahead, giving you an even broader and more precise view of market movements.
See the Future, Now:
• Track upcoming RSI & RSI MA crossovers in advance.
• Identify potential reversal zones before price reacts.
• Uncover statistical behavior patterns that would normally go unnoticed.
40+ Intelligent Conditions:
The new layer of conditions is designed to detect multiple high-probability scenarios based on historical patterns and predictive modeling. Each additional forecast is a window into the price's future, powered by robust mathematics and advanced algorithmic logic.
Full Customization:
All parameters can be tailored to fit your strategy – from smoothing periods to prediction sensitivity. You have complete control to turn raw data into smart decisions.
Innovative, Accurate, Unique:
This isn’t just an upgrade. It’s a quantum leap in technical analysis.
RSI Full Forecast is the first of its kind: an indicator that blends statistical analysis, machine learning, and visual design to create a true real-time predictive system.
⯁  SCIENTIFIC BASIS LINEAR REGRESSION 
Linear Regression is a fundamental method of statistics and machine learning, used to model the relationship between a dependent variable y and one or more independent variables 𝑥.
The general formula for a simple linear regression is given by:
y = β₀ + β₁x + ε
β₁ = Σ((xᵢ - x̄)(yᵢ - ȳ)) / Σ((xᵢ - x̄)²)
β₀ = ȳ - β₁x̄
Where:
y   = is the predicted variable (e.g. future value of RSI)
x   = is the explanatory variable (e.g. time or bar index)
β0 = is the intercept (value of 𝑦 when 𝑥 = 0)
𝛽1 = is the slope of the line (rate of change)
ε   = is the random error term
The goal is to estimate the coefficients 𝛽0 and 𝛽1 so as to minimize the sum of the squared errors — the so-called Random Error Method Least Squares.
⯁  LEAST SQUARES ESTIMATION 
To minimize the error between predicted and observed values, we use the following formulas:
β₁ =   /  
β₀ = ȳ - β₁x̄
Where:
∑ = sum
x̄ = mean of x
ȳ = mean of y
x_i, y_i = individual values of the variables.
Where:
x_i and y_i are the means of the independent and dependent variables, respectively.
i ranges from 1 to n, the number of observations.
These equations guarantee the best linear unbiased estimator, according to the Gauss-Markov theorem, assuming homoscedasticity and linearity.
⯁  LINEAR REGRESSION IN MACHINE LEARNING 
Linear regression is one of the cornerstones of supervised learning. Its simplicity and ability to generate accurate quantitative predictions make it essential in AI systems, predictive algorithms, time series analysis, and automated trading strategies.
By applying this model to the RSI, you are literally putting artificial intelligence at the heart of a classic indicator, bringing a new dimension to technical analysis.
⯁  VISUAL INTERPRETATION 
Imagine an RSI time series like this:
Time →    
RSI    →    
The regression line will smooth these values and extend them n periods into the future, creating a predicted trajectory based on the historical moment. This line becomes the predicted RSI, which can be crossed with the actual RSI to generate more intelligent signals.
⯁  SUMMARY OF SCIENTIFIC CONCEPTS USED 
 
 Linear Regression Models the relationship between variables using a straight line.
 Least Squares Minimizes the sum of squared errors between prediction and reality.
 Time Series Forecasting Estimates future values based on historical data.
 Supervised Learning Trains models to predict outputs from known inputs.
 Statistical Smoothing Reduces noise and reveals underlying trends.
 
⯁  WHY THIS INDICATOR IS REVOLUTIONARY 
 
 Scientifically-based: Based on statistical theory and mathematical inference.
 Unprecedented: First public RSI with least squares predictive modeling.
 Intelligent: Built with machine learning logic.
 Practical: Generates forward-thinking signals.
 Customizable: Flexible for any trading strategy.
 
⯁  CONCLUSION 
By combining RSI with linear regression, this indicator allows a trader to predict market momentum, not just follow it.
RSI Full Forecast   is not just an indicator — it is a scientific breakthrough in technical analysis technology.
⯁ Example of simple linear regression, which has one independent variable:
⯁ In linear regression, observations ( red ) are considered to be the result of random deviations ( green ) from an underlying relationship ( blue ) between a dependent variable ( y ) and an independent variable ( x ).
⯁ Visualizing heteroscedasticity in a scatterplot against 100 random fitted values using Matlab:
⯁ The data sets in the Anscombe's quartet are designed to have approximately the same linear regression line (as well as nearly identical means, standard deviations, and correlations) but are graphically very different. This illustrates the pitfalls of relying solely on a fitted model to understand the relationship between variables.
⯁ The result of fitting a set of data points with a quadratic function:
_________________________________________________
🔮 Linear Regression: PineScript Technical Parameters 🔮
_________________________________________________
Forecast Types:
• Flat: Assumes prices will remain the same.
• Linreg: Makes a 'Linear Regression' forecast for n periods.
Technical Information:
ta.linreg (built-in function)
Linear regression curve. A line that best fits the specified prices over a user-defined time period. It is calculated using the least squares method. The result of this function is calculated using the formula: linreg = intercept + slope * (length - 1 - offset), where intercept and slope are the values calculated using the least squares method on the source series.
Syntax:
• Function: ta.linreg()
Parameters:
• source: Source price series.
• length: Number of bars (period).
• offset: Offset.
• return: Linear regression curve.
This function has been cleverly applied to the RSI, making it capable of projecting future values based on past statistical trends.
______________________________________________________
______________________________________________________
 ⯁ WHAT IS THE RSI❓ 
The Relative Strength Index (RSI) is a technical analysis indicator developed by J. Welles Wilder. It measures the magnitude of recent price movements to evaluate overbought or oversold conditions in a market. The RSI is an oscillator that ranges from 0 to 100 and is commonly used to identify potential reversal points, as well as the strength of a trend.
 ⯁ HOW TO USE THE RSI❓ 
The RSI is calculated based on average gains and losses over a specified period (usually 14 periods). It is plotted on a scale from 0 to 100 and includes three main zones:
  •   Overbought:  When the RSI is above 70, indicating that the asset may be overbought.
  •   Oversold:  When the RSI is below 30, indicating that the asset may be oversold.
  •   Neutral Zone:  Between 30 and 70, where there is no clear signal of overbought or oversold conditions.
______________________________________________________
______________________________________________________
 ⯁ ENTRY CONDITIONS 
The conditions below are fully flexible and allow for complete customization of the signal.
______________________________________________________
______________________________________________________
 🔹 CONDITIONS TO BUY 📈 
______________________________________________________
  •  Signal Validity: The signal will remain valid for  X bars .
  •  Signal Sequence: Configurable as  AND  or  OR .
📈 RSI Conditions:
🔹 RSI > Upper
🔹 RSI < Upper
🔹 RSI > Lower
🔹 RSI < Lower
🔹 RSI > Middle
🔹 RSI < Middle
🔹 RSI > MA
🔹 RSI < MA
📈 MA Conditions:
🔹 MA > Upper
🔹 MA < Upper
🔹 MA > Lower
🔹 MA < Lower
📈 Crossovers:
🔹 RSI (Crossover) Upper
🔹 RSI (Crossunder) Upper
🔹 RSI (Crossover) Lower
🔹 RSI (Crossunder) Lower
🔹 RSI (Crossover) Middle
🔹 RSI (Crossunder) Middle
🔹 RSI (Crossover) MA
🔹 RSI (Crossunder) MA
🔹 MA (Crossover) Upper
🔹 MA (Crossunder) Upper
🔹 MA (Crossover) Lower
🔹 MA (Crossunder) Lower
📈 RSI Divergences:
🔹 RSI Divergence Bull
🔹 RSI Divergence Bear
📈 RSI Forecast:
🔹 RSI (Crossover) MA Forecast
🔹 RSI (Crossunder) MA Forecast
🔹 RSI Forecast 1 > MA Forecast 1
🔹 RSI Forecast 1 < MA Forecast 1
🔹 RSI Forecast 2 > MA Forecast 2
🔹 RSI Forecast 2 < MA Forecast 2
🔹 RSI Forecast 3 > MA Forecast 3
🔹 RSI Forecast 3 < MA Forecast 3
🔹 RSI Forecast 4 > MA Forecast 4
🔹 RSI Forecast 4 < MA Forecast 4
🔹 RSI Forecast 5 > MA Forecast 5
🔹 RSI Forecast 5 < MA Forecast 5
🔹 RSI Forecast 6 > MA Forecast 6
🔹 RSI Forecast 6 < MA Forecast 6
🔹 RSI Forecast 7 > MA Forecast 7
🔹 RSI Forecast 7 < MA Forecast 7
🔹 RSI Forecast 8 > MA Forecast 8
🔹 RSI Forecast 8 < MA Forecast 8
🔹 RSI Forecast 9 > MA Forecast 9
🔹 RSI Forecast 9 < MA Forecast 9
🔹 RSI Forecast 10 > MA Forecast 10
🔹 RSI Forecast 10 < MA Forecast 10
🔹 RSI Forecast 11 > MA Forecast 11
🔹 RSI Forecast 11 < MA Forecast 11
🔹 RSI Forecast 12 > MA Forecast 12
🔹 RSI Forecast 12 < MA Forecast 12
🔹 RSI Forecast 13 > MA Forecast 13
🔹 RSI Forecast 13 < MA Forecast 13
🔹 RSI Forecast 14 > MA Forecast 14
🔹 RSI Forecast 14 < MA Forecast 14
🔹 RSI Forecast 15 > MA Forecast 15
🔹 RSI Forecast 15 < MA Forecast 15
🔹 RSI Forecast 16 > MA Forecast 16
🔹 RSI Forecast 16 < MA Forecast 16
🔹 RSI Forecast 17 > MA Forecast 17
🔹 RSI Forecast 17 < MA Forecast 17
🔹 RSI Forecast 18 > MA Forecast 18
🔹 RSI Forecast 18 < MA Forecast 18
🔹 RSI Forecast 19 > MA Forecast 19
🔹 RSI Forecast 19 < MA Forecast 19
🔹 RSI Forecast 20 > MA Forecast 20
🔹 RSI Forecast 20 < MA Forecast 20
______________________________________________________
______________________________________________________
 🔸 CONDITIONS TO SELL 📉 
______________________________________________________
  •  Signal Validity: The signal will remain valid for  X bars .
  •  Signal Sequence: Configurable as  AND  or  OR .
📉 RSI Conditions:
🔸 RSI > Upper
🔸 RSI < Upper
🔸 RSI > Lower
🔸 RSI < Lower
🔸 RSI > Middle
🔸 RSI < Middle
🔸 RSI > MA
🔸 RSI < MA
📉 MA Conditions:
🔸 MA > Upper
🔸 MA < Upper
🔸 MA > Lower
🔸 MA < Lower
📉 Crossovers:
🔸 RSI (Crossover) Upper
🔸 RSI (Crossunder) Upper
🔸 RSI (Crossover) Lower
🔸 RSI (Crossunder) Lower
🔸 RSI (Crossover) Middle
🔸 RSI (Crossunder) Middle
🔸 RSI (Crossover) MA
🔸 RSI (Crossunder) MA
🔸 MA (Crossover) Upper
🔸 MA (Crossunder) Upper
🔸 MA (Crossover) Lower
🔸 MA (Crossunder) Lower
📉 RSI Divergences:
🔸 RSI Divergence Bull
🔸 RSI Divergence Bear
📉 RSI Forecast:
🔸 RSI (Crossover) MA Forecast
🔸 RSI (Crossunder) MA Forecast
🔸 RSI Forecast 1 > MA Forecast 1
🔸 RSI Forecast 1 < MA Forecast 1
🔸 RSI Forecast 2 > MA Forecast 2
🔸 RSI Forecast 2 < MA Forecast 2
🔸 RSI Forecast 3 > MA Forecast 3
🔸 RSI Forecast 3 < MA Forecast 3
🔸 RSI Forecast 4 > MA Forecast 4
🔸 RSI Forecast 4 < MA Forecast 4
🔸 RSI Forecast 5 > MA Forecast 5
🔸 RSI Forecast 5 < MA Forecast 5
🔸 RSI Forecast 6 > MA Forecast 6
🔸 RSI Forecast 6 < MA Forecast 6
🔸 RSI Forecast 7 > MA Forecast 7
🔸 RSI Forecast 7 < MA Forecast 7
🔸 RSI Forecast 8 > MA Forecast 8
🔸 RSI Forecast 8 < MA Forecast 8
🔸 RSI Forecast 9 > MA Forecast 9
🔸 RSI Forecast 9 < MA Forecast 9
🔸 RSI Forecast 10 > MA Forecast 10
🔸 RSI Forecast 10 < MA Forecast 10
🔸 RSI Forecast 11 > MA Forecast 11
🔸 RSI Forecast 11 < MA Forecast 11
🔸 RSI Forecast 12 > MA Forecast 12
🔸 RSI Forecast 12 < MA Forecast 12
🔸 RSI Forecast 13 > MA Forecast 13
🔸 RSI Forecast 13 < MA Forecast 13
🔸 RSI Forecast 14 > MA Forecast 14
🔸 RSI Forecast 14 < MA Forecast 14
🔸 RSI Forecast 15 > MA Forecast 15
🔸 RSI Forecast 15 < MA Forecast 15
🔸 RSI Forecast 16 > MA Forecast 16
🔸 RSI Forecast 16 < MA Forecast 16
🔸 RSI Forecast 17 > MA Forecast 17
🔸 RSI Forecast 17 < MA Forecast 17
🔸 RSI Forecast 18 > MA Forecast 18
🔸 RSI Forecast 18 < MA Forecast 18
🔸 RSI Forecast 19 > MA Forecast 19
🔸 RSI Forecast 19 < MA Forecast 19
🔸 RSI Forecast 20 > MA Forecast 20
🔸 RSI Forecast 20 < MA Forecast 20
______________________________________________________
______________________________________________________
 🤖 AUTOMATION 🤖 
• You can automate the BUY and SELL signals of this indicator.
______________________________________________________
______________________________________________________
 ⯁ UNIQUE FEATURES 
______________________________________________________
 
 Linear Regression:  (Forecast) 
 Signal Validity: The signal will remain valid for  X bars 
 Signal Sequence: Configurable as  AND/OR 
 Condition Table: BUY/SELL
 Condition Labels: BUY/SELL
 Plot Labels in the Graph Above: BUY/SELL
 Automate and Monitor Signals/Alerts: BUY/SELL
 
 
 Linear Regression (Forecast)
 Signal Validity: The signal will remain valid for  X bars 
 Signal Sequence: Configurable as  AND/OR 
 Condition Table: BUY/SELL
 Condition Labels: BUY/SELL
 Plot Labels in the Graph Above: BUY/SELL
 Automate and Monitor Signals/Alerts: BUY/SELL
 
______________________________________________________
 📜 SCRIPT :  RSI Full Forecast  
🎴 Art by  : @Titans_Invest & @DiFlip
👨💻 Dev by : @Titans_Invest & @DiFlip
🎑 Titans Invest — The Wizards Without Gloves 🧤
✨ Enjoy! 
______________________________________________________
 o Mission 🗺
• Inspire Traders to manifest Magic in the Market.
o Vision 𐓏
• To elevate collective Energy 𐓷𐓏
 RSI Overbought/Oversold + Divergence Indicator (new)//@version=5
indicator('CryptoSignalScanner - RSI Overbought/Oversold + Divergence Indicator (new)', 
//---------------------------------------------------------------------------------------------------------------------------------
//--- Define Colors ---------------------------------------------------------------------------------------------------------------
//---------------------------------------------------------------------------------------------------------------------------------
vWhite  = #FFFFFF
vViolet = #C77DF3
vIndigo = #8A2BE2
vBlue   = #009CDF
vGreen  = #5EBD3E
vYellow = #FFB900
vRed    = #E23838
longColor  = color.green
shortColor = color.red
textColor  = color.white
bullishColor = color.rgb(38,166,154,0) //Used in the display table
bearishColor = color.rgb(239,83,79,0) //Used in the display table
nomatchColor = color.silver //Used in the display table
//---------------------------------------------------------------------------------------------------------------------------------------------------------------------
//--- Functions--------------------------------------------------------------------------------------------------------------------------------------------------------
//---------------------------------------------------------------------------------------------------------------------------------------------------------------------
TF2txt(TF) =>
    switch TF
        "S"    => "RSI 1s:"
        "5S"    => "RSI 5s:"
        "10S"   => "RSI 10s:"
        "15S"   => "RSI 15s:"
        "30S"   => "RSI 30s"
        "1"     => "RSI 1m:"
        "3"     => "RSI 3m:"
        "5"     => "RSI 5m:"
        "15"    => "RSI 15m:"
        "30"    => "RSI 30m"
        "45"    => "RSI 45m"
        "60"    => "RSI 1h:"
        "120"   => "RSI 2h:"
        "180"   => "RSI 3h:"
        "240"   => "RSI 4h:"
        "480"   => "RSI 8h:"
        "D"     => "RSI 1D:"
        "1D"    => "RSI 1D:"
        "2D"    => "RSI 2D:"
        "3D"    => "RSI 2D:"
        "3D"    => "RSI 3W:"
        "W"     => "RSI 1W:"
        "1W"    => "RSI 1W:"
        "M"     => "RSI 1M:"
        "1M"    => "RSI 1M:"
        "3M"    => "RSI 3M:"
        "6M"    => "RSI 6M:"
        "12M"   => "RSI 12M:"
//---------------------------------------------------------------------------------------------------------------------------------------------------------------------
//--- Show/Hide Settings ----------------------------------------------------------------------------------------------------------------------------------------------
//---------------------------------------------------------------------------------------------------------------------------------------------------------------------
rsiShowInput          = input(true, title='Show RSI', group='Show/Hide Settings')
maShowInput           = input(false, title='Show MA', group='Show/Hide Settings')
showRSIMAInput        = input(true, title='Show RSIMA Cloud', group='Show/Hide Settings')
rsiBandShowInput      = input(true, title='Show Oversold/Overbought Lines', group='Show/Hide Settings')
rsiBandExtShowInput   = input(true, title='Show Oversold/Overbought Extended Lines', group='Show/Hide Settings')
rsiHighlightShowInput = input(true, title='Show Oversold/Overbought Highlight Lines', group='Show/Hide Settings')
DivergenceShowInput   = input(true, title='Show RSI Divergence Labels', group='Show/Hide Settings')
//---------------------------------------------------------------------------------------------------------------------------------------------------------------------
//--- Table Settings --------------------------------------------------------------------------------------------------------------------------------------------------
//---------------------------------------------------------------------------------------------------------------------------------------------------------------------
rsiShowTable      = input(true, title='Show RSI Table Information box', group="RSI Table Settings")
rsiTablePosition  = input.string(title='Location', defval='middle_right', options= , group="RSI Table Settings", inline='1')
rsiTextSize       = input.string(title=' Size', defval='small', options= , group="RSI Table Settings", inline='1')
rsiShowTF1 = input(true, title='Show TimeFrame1', group="RSI Table Settings", inline='tf1')
rsiTF1     = input.timeframe("15", title=" Time", group="RSI Table Settings", inline='tf1')
rsiShowTF2 = input(true, title='Show TimeFrame2', group="RSI Table Settings", inline='tf2')
rsiTF2     = input.timeframe("60", title=" Time", group="RSI Table Settings", inline='tf2')
rsiShowTF3 = input(true, title='Show TimeFrame3', group="RSI Table Settings", inline='tf3')
rsiTF3     = input.timeframe("240", title=" Time", group="RSI Table Settings", inline='tf3')
rsiShowTF4 = input(true, title='Show TimeFrame4', group="RSI Table Settings", inline='tf4')
rsiTF4     = input.timeframe("D", title=" Time", group="RSI Table Settings", inline='tf4')
rsiShowHist = input(true, title='Show RSI Historical Columns', group="RSI Table Settings", tooltip='Show the information of the 2 previous closed candles')
//---------------------------------------------------------------------------------------------------------------------------------------------------------------------
//--- RSI Input Settings ----------------------------------------------------------------------------------------------------------------------------------------------
//---------------------------------------------------------------------------------------------------------------------------------------------------------------------
rsiSourceInput  = input.source(close, 'Source', group='RSI Settings')
rsiLengthInput  = input.int(14, minval=1, title='RSI Length', group='RSI Settings', tooltip='Here we set the RSI lenght')
rsiColorInput   = input.color(#26a69a, title="RSI Color",  group='RSI Settings')
rsimaColorInput = input.color(#ef534f, title="RSIMA Color",  group='RSI Settings')
rsiBandColorInput = input.color(#787B86, title="RSI Band Color",  group='RSI Settings')
rsiUpperBandExtInput = input.int(title='RSI Overbought Extended Line', defval=80, minval=50, maxval=100, group='RSI Settings')
rsiUpperBandInput   = input.int(title='RSI Overbought Line', defval=70, minval=50, maxval=100, group='RSI Settings')
rsiLowerBandInput   = input.int(title='RSI Oversold Line', defval=30, minval=0, maxval=50, group='RSI Settings')
rsiLowerBandExtInput = input.int(title='RSI Oversold Extended Line', defval=20, minval=0, maxval=50, group='RSI Settings')
//---------------------------------------------------------------------------------------------------------------------------------------------------------------------
//--- MA Input Settings -----------------------------------------------------------------------------------------------------------------------------------------------
//---------------------------------------------------------------------------------------------------------------------------------------------------------------------
maTypeInput = input.string("EMA", title="MA Type", options= , group="MA Settings")
maLengthInput = input.int(14, title="MA Length", group="MA Settings")
maColorInput = input.color(color.yellow, title="MA Color",  group='MA Settings') //#7E57C2
//---------------------------------------------------------------------------------------------------------------------------------------------------------------------
//--- Divergence Input Settings ---------------------------------------------------------------------------------------------------------------------------------------
//---------------------------------------------------------------------------------------------------------------------------------------------------------------------
lbrInput        = input(title="Pivot Lookback Right", defval=2, group='RSI Divergence Settings')
lblInput        = input(title="Pivot Lookback Left", defval=2, group='RSI Divergence Settings')
lbRangeMaxInput = input(title="Max of Lookback Range", defval=10, group='RSI Divergence Settings')
lbRangeMinInput = input(title="Min of Lookback Range", defval=2, group='RSI Divergence Settings')
plotBullInput       = input(title="Plot Bullish", defval=true, group='RSI Divergence Settings')
plotHiddenBullInput = input(title="Plot Hidden Bullish", defval=true, group='RSI Divergence Settings')
plotBearInput       = input(title="Plot Bearish", defval=true, group='RSI Divergence Settings')
plotHiddenBearInput = input(title="Plot Hidden Bearish", defval=true, group='RSI Divergence Settings')
//---------------------------------------------------------------------------------------------------------------------------------------------------------------------
//--- RSI Calculation -------------------------------------------------------------------------------------------------------------------------------------------------
//---------------------------------------------------------------------------------------------------------------------------------------------------------------------
rsi         = ta.rsi(rsiSourceInput, rsiLengthInput)
rsiprevious = rsi 
  = request.security(syminfo.tickerid, rsiTF1,  [rsi, rsi , rsi ], lookahead=barmerge.lookahead_on)
  = request.security(syminfo.tickerid, rsiTF2,  [rsi, rsi , rsi ], lookahead=barmerge.lookahead_on)
  = request.security(syminfo.tickerid, rsiTF3,  [rsi, rsi , rsi ], lookahead=barmerge.lookahead_on)
  = request.security(syminfo.tickerid, rsiTF4,  [rsi, rsi , rsi ], lookahead=barmerge.lookahead_on)
//---------------------------------------------------------------------------------------------------------------------------------------------------------------------
//--- MA Calculation -------------------------------------------------------------------------------------------------------------------------------------------------
//---------------------------------------------------------------------------------------------------------------------------------------------------------------------
ma(source, length, type) =>
    switch type
        "SMA" => ta.sma(source, length)
        "Bollinger Bands" => ta.sma(source, length)
        "EMA" => ta.ema(source, length)
        "SMMA (RMA)" => ta.rma(source, length)
        "WMA" => ta.wma(source, length)
        "VWMA" => ta.vwma(source, length)
rsiMA         = ma(rsi, maLengthInput, maTypeInput)
rsiMAPrevious = rsiMA 
//---------------------------------------------------------------------------------------------------------------------------------------------------------------------
//--- Stoch RSI Settings + Calculation --------------------------------------------------------------------------------------------------------------------------------
//---------------------------------------------------------------------------------------------------------------------------------------------------------------------
showStochRSI    = input(false, title="Show Stochastic RSI", group='Stochastic RSI Settings')
smoothK         = input.int(title="Stochastic K", defval=3, minval=1,  maxval=10, group='Stochastic RSI Settings')
smoothD         = input.int(title="Stochastic D", defval=4, minval=1,  maxval=10, group='Stochastic RSI Settings')
lengthRSI       = input.int(title="Stochastic RSI Lenght", defval=14, minval=1, group='Stochastic RSI Settings')
lengthStoch     = input.int(title="Stochastic Lenght", defval=14, minval=1, group='Stochastic RSI Settings')
colorK          = input.color(color.rgb(41,98,255,0), title="K Color",  group='Stochastic RSI Settings', inline="1")
colorD          = input.color(color.rgb(205,109,0,0), title="D Color",  group='Stochastic RSI Settings', inline="1")
StochRSI    = ta.rsi(rsiSourceInput, lengthRSI)
k       = ta.sma(ta.stoch(StochRSI, StochRSI, StochRSI, lengthStoch), smoothK) //Blue Line
d       = ta.sma(k, smoothD) //Red Line
//---------------------------------------------------------------------------------------------------------------------------------------------------------------------
//--- Divergence Settings ------------------------------------------------------------------------------------------------------------------------------------------
//---------------------------------------------------------------------------------------------------------------------------------------------------------------------
bearColor = color.red
bullColor = color.green
hiddenBullColor = color.new(color.green, 50)
hiddenBearColor = color.new(color.red, 50)
//textColor = color.white
noneColor = color.new(color.white, 100)
osc = rsi
plFound = na(ta.pivotlow(osc, lblInput, lbrInput)) ? false : true
phFound = na(ta.pivothigh(osc, lblInput, lbrInput)) ? false : true
_inRange(cond) =>
	bars = ta.barssince(cond == true)
	lbRangeMinInput <= bars and bars <= lbRangeMaxInput 
//---------------------------------------------------------------------------------------------------------------------------------------------------------------------
//--- Define Plot & Line Colors ---------------------------------------------------------------------------------------------------------------------------------------
//---------------------------------------------------------------------------------------------------------------------------------------------------------------------
rsiColor = rsi >= rsiMA ? rsiColorInput : rsimaColorInput
//---------------------------------------------------------------------------------------------------------------------------------------------------------------------
//--- Plot Lines ------------------------------------------------------------------------------------------------------------------------------------------------------
//---------------------------------------------------------------------------------------------------------------------------------------------------------------------
// Create a horizontal line at a specific price level
myLine = line.new(bar_index , 75, bar_index, 75, color = color.rgb(187, 14, 14), width = 2)
bottom = line.new(bar_index , 50, bar_index, 50, color = color.rgb(223, 226, 28), width = 2)
mymainLine = line.new(bar_index , 60, bar_index, 60, color = color.rgb(13, 154, 10), width = 3)
hline(50, title='RSI Baseline', color=color.new(rsiBandColorInput, 50), linestyle=hline.style_solid, editable=false)   
hline(rsiBandExtShowInput ? rsiUpperBandExtInput : na,  title='RSI Upper Band',  color=color.new(rsiBandColorInput, 10), linestyle=hline.style_dashed, editable=false)  
hline(rsiBandShowInput ? rsiUpperBandInput : na,  title='RSI Upper Band',  color=color.new(rsiBandColorInput, 10), linestyle=hline.style_dashed, editable=false) 
hline(rsiBandShowInput ? rsiLowerBandInput : na,  title='RSI Upper Band',  color=color.new(rsiBandColorInput, 10), linestyle=hline.style_dashed, editable=false) 
hline(rsiBandExtShowInput ? rsiLowerBandExtInput : na,  title='RSI Upper Band',  color=color.new(rsiBandColorInput, 10), linestyle=hline.style_dashed, editable=false)
bgcolor(rsiHighlightShowInput ? rsi >= rsiUpperBandExtInput ? color.new(rsiColorInput, 70) : na : na, title="Show Extended Oversold Highlight", editable=false)
bgcolor(rsiHighlightShowInput ? rsi >= rsiUpperBandInput ? rsi < rsiUpperBandExtInput ? color.new(#64ffda, 90) : na : na: na, title="Show Overbought Highlight", editable=false)
bgcolor(rsiHighlightShowInput ? rsi <= rsiLowerBandInput ? rsi > rsiLowerBandExtInput ? color.new(#F43E32, 90) : na : na : na, title="Show Extended Oversold Highlight", editable=false)
bgcolor(rsiHighlightShowInput ? rsi <= rsiLowerBandInput ? color.new(rsimaColorInput, 70) : na : na, title="Show Oversold Highlight", editable=false)
maPlot     = plot(maShowInput ? rsiMA : na, title='MA', color=color.new(maColorInput,0), linewidth=1)
rsiMAPlot  = plot(showRSIMAInput ? rsiMA : na, title="RSI EMA", color=color.new(rsimaColorInput,0), editable=false, display=display.none)
rsiPlot    = plot(rsiShowInput ? rsi : na, title='RSI', color=color.new(rsiColor,0), linewidth=1)
fill(rsiPlot, rsiMAPlot, color=color.new(rsiColor, 60), title="RSIMA Cloud")
plot(showStochRSI ? k : na, title='Stochastic K', color=colorK, linewidth=1)
plot(showStochRSI ? d : na, title='Stochastic D', color=colorD, linewidth=1)
//---------------------------------------------------------------------------------------------------------------------------------------------------------------------
//--- Plot Divergence -------------------------------------------------------------------------------------------------------------------------------------------------
//---------------------------------------------------------------------------------------------------------------------------------------------------------------------
// Regular Bullish
// Osc: Higher Low
oscHL = osc  > ta.valuewhen(plFound, osc , 1) and _inRange(plFound )
// Price: Lower Low
priceLL = low  < ta.valuewhen(plFound, low , 1)
bullCond = plotBullInput and priceLL and oscHL and plFound
plot(
     plFound ? osc  : na,
     offset=-lbrInput,
     title="Regular Bullish",
     linewidth=2,
     color=(bullCond ? bullColor : noneColor)
     )
plotshape(
     DivergenceShowInput ? bullCond ? osc  : na : na,
     offset=-lbrInput,
     title="Regular Bullish Label",
     text=" Bull ",
     style=shape.labelup,
     location=location.absolute,
     color=bullColor,
     textcolor=textColor
     )
//------------------------------------------------------------------------------
// Hidden Bullish
// Osc: Lower Low
oscLL = osc  < ta.valuewhen(plFound, osc , 1) and _inRange(plFound )
// Price: Higher Low
priceHL = low  > ta.valuewhen(plFound, low , 1)
hiddenBullCond = plotHiddenBullInput and priceHL and oscLL and plFound
plot(
	 plFound ? osc  : na,
	 offset=-lbrInput,
	 title="Hidden Bullish",
	 linewidth=2,
	 color=(hiddenBullCond ? hiddenBullColor : noneColor)
	 )
plotshape(
	 DivergenceShowInput ? hiddenBullCond ? osc  : na : na,
	 offset=-lbrInput,
	 title="Hidden Bullish Label",
	 text=" H Bull ",
	 style=shape.labelup,
	 location=location.absolute,
	 color=bullColor,
	 textcolor=textColor
	 )
//------------------------------------------------------------------------------
// Regular Bearish
// Osc: Lower High
oscLH = osc  < ta.valuewhen(phFound, osc , 1) and _inRange(phFound )
// Price: Higher High
priceHH = high  > ta.valuewhen(phFound, high , 1)
bearCond = plotBearInput and priceHH and oscLH and phFound
plot(
	 phFound ? osc  : na,
	 offset=-lbrInput,
	 title="Regular Bearish",
	 linewidth=2,
	 color=(bearCond ? bearColor : noneColor)
	 )
plotshape(
	 DivergenceShowInput ? bearCond ? osc  : na : na,
	 offset=-lbrInput,
	 title="Regular Bearish Label",
	 text=" Bear ",
	 style=shape.labeldown,
	 location=location.absolute,
	 color=bearColor,
	 textcolor=textColor
	 )
//------------------------------------------------------------------------------
// Hidden Bearish
// Osc: Higher High
oscHH = osc  > ta.valuewhen(phFound, osc , 1) and _inRange(phFound )
// Price: Lower High
priceLH = high  < ta.valuewhen(phFound, high , 1)
hiddenBearCond = plotHiddenBearInput and priceLH and oscHH and phFound
plot(
	 phFound ? osc  : na,
	 offset=-lbrInput,
	 title="Hidden Bearish",
	 linewidth=2,
	 color=(hiddenBearCond ? hiddenBearColor : noneColor)
	 )
plotshape(
	 DivergenceShowInput ? hiddenBearCond ? osc  : na : na,
	 offset=-lbrInput,
	 title="Hidden Bearish Label",
	 text=" H Bear ",
	 style=shape.labeldown,
	 location=location.absolute,
	 color=bearColor,
	 textcolor=textColor
	 )
//---------------------------------------------------------------------------------------------------------------------------------------------------------------------
//--- Check RSI Lineup ------------------------------------------------------------------------------------------------------------------------------------------------
//---------------------------------------------------------------------------------------------------------------------------------------------------------------------
bullTF =  rsi > rsi  and rsi  > rsi 
bearTF =  rsi < rsi  and rsi  < rsi 
bullTF1 =  rsi1 > rsi1_1 and rsi1_1 > rsi1_2
bearTF1 =  rsi1 < rsi1_1 and rsi1_1 < rsi1_2
bullTF2 =  rsi2 > rsi2_1 and rsi2_1 > rsi2_2
bearTF2 =  rsi2 < rsi2_1 and rsi2_1 < rsi2_2
bullTF3 =  rsi3 > rsi3_1 and rsi3_1 > rsi3_2
bearTF3 =  rsi3 < rsi3_1 and rsi3_1 < rsi3_2
bullTF4 =  rsi4 > rsi4_1 and rsi4_1 > rsi4_2
bearTF4 =  rsi4 < rsi4_1 and rsi4_1 < rsi4_2
bbTxt(bull,bear) =>
    bull ? "BULLISH" : bear ? "BEARISCH" : 'NO LINEUP'
bbColor(bull,bear) =>
    bull ? bullishColor : bear ? bearishColor : nomatchColor
newTC(tBox, col, row, txt, width, txtColor, bgColor, txtHA, txtSize) =>
    table.cell(table_id=tBox,column=col, row=row, text=txt, width=width,text_color=txtColor,bgcolor=bgColor, text_halign=txtHA, text_size=txtSize)
//---------------------------------------------------------------------------------------------------------------------------------------------------------------------
//--- Define RSI Table Setting ----------------------------------------------------------------------------------------------------------------------------------------
//---------------------------------------------------------------------------------------------------------------------------------------------------------------------
width_c0 = 0
width_c1 = 0
if rsiShowTable
    var tBox = table.new(position=rsiTablePosition, columns=5, rows=6, bgcolor=color.rgb(18,22,33,50), frame_color=color.black, frame_width=1, border_color=color.black, border_width=1)
    newTC(tBox, 0,1,"RSI Current",width_c0,color.orange,color.rgb(0,0,0,100),'right',rsiTextSize)
    newTC(tBox, 1,1,str.format(" {0,number,#.##} ", rsi),width_c0,vWhite,rsi < 50 ? bearishColor:bullishColor,'left',rsiTextSize)
    newTC(tBox, 4,1,bbTxt(bullTF, bearTF),width_c0,vWhite,bbColor(bullTF, bearTF),'center',rsiTextSize)
    if rsiShowHist
        newTC(tBox, 2,1,str.format(" {0,number,#.##} ", rsi ),width_c0,vWhite,rsi  < 50 ? bearishColor:bullishColor,'left',rsiTextSize)
        newTC(tBox, 3,1,str.format(" {0,number,#.##} ", rsi ),width_c0,vWhite,rsi  < 50 ? bearishColor:bullishColor,'left',rsiTextSize)
    if rsiShowTF1
        newTC(tBox, 0,2,TF2txt(rsiTF1),width_c0,vWhite,color.rgb(0,0,0,100),'right',rsiTextSize)
        newTC(tBox, 1,2,str.format(" {0,number,#.##} ", rsi1),width_c0,vWhite,rsi1 < 50 ? bearishColor:bullishColor,'left',rsiTextSize)
        newTC(tBox, 4,2,bbTxt(bullTF1, bearTF1),width_c0,vWhite,bbColor(bullTF1,bearTF1),'center',rsiTextSize)
        if rsiShowHist
            newTC(tBox, 2,2,str.format(" {0,number,#.##} ", rsi1_1),width_c0,vWhite,rsi1_1 < 50 ? bearishColor:bullishColor,'left',rsiTextSize)
            newTC(tBox, 3,2,str.format(" {0,number,#.##} ", rsi1_2),width_c0,vWhite,rsi1_2 < 50 ? bearishColor:bullishColor,'left',rsiTextSize)
    if rsiShowTF2
        newTC(tBox, 0,3,TF2txt(rsiTF2),width_c0,vWhite,color.rgb(0,0,0,100),'right',rsiTextSize)
        newTC(tBox, 1,3,str.format(" {0,number,#.##} ", rsi2),width_c0,vWhite,rsi2 < 50 ? bearishColor:bullishColor,'left',rsiTextSize)
        newTC(tBox, 4,3,bbTxt(bullTF2, bearTF2),width_c0,vWhite,bbColor(bullTF2,bearTF2),'center',rsiTextSize)
        if rsiShowHist
            newTC(tBox, 2,3,str.format(" {0,number,#.##} ", rsi2_1),width_c0,vWhite,rsi2_1 < 50 ? bearishColor:bullishColor,'left',rsiTextSize)
            newTC(tBox, 3,3,str.format(" {0,number,#.##} ", rsi2_2),width_c0,vWhite,rsi2_2 < 50 ? bearishColor:bullishColor,'left',rsiTextSize)
    if rsiShowTF3
        newTC(tBox, 0,4,TF2txt(rsiTF3),width_c0,vWhite,color.rgb(0,0,0,100),'right',rsiTextSize)
        newTC(tBox, 1,4,str.format(" {0,number,#.##} ", rsi3),width_c0,vWhite,rsi3 < 50 ? bearishColor:bullishColor,'left',rsiTextSize)
        newTC(tBox, 4,4,bbTxt(bullTF3, bearTF3),width_c0,vWhite,bbColor(bullTF3,bearTF3),'center',rsiTextSize)
        if rsiShowHist
            newTC(tBox, 2,4,str.format(" {0,number,#.##} ", rsi3_1),width_c0,vWhite,rsi3_1 < 50 ? bearishColor:bullishColor,'left',rsiTextSize)
            newTC(tBox, 3,4,str.format(" {0,number,#.##} ", rsi3_2),width_c0,vWhite,rsi3_2 < 50 ? bearishColor:bullishColor,'left',rsiTextSize)
    if rsiShowTF4
        newTC(tBox, 0,5,TF2txt(rsiTF4),width_c0,vWhite,color.rgb(0,0,0,100),'right',rsiTextSize)
        newTC(tBox, 1,5,str.format(" {0,number,#.##} ", rsi4),width_c0,vWhite,rsi4 < 50 ? bearishColor:bullishColor,'left',rsiTextSize)
        newTC(tBox, 4,5,bbTxt(bullTF4, bearTF4),width_c0,vWhite,bbColor(bullTF4,bearTF4),'center',rsiTextSize)
        if rsiShowHist
            newTC(tBox, 2,5,str.format(" {0,number,#.##} ", rsi4_1),width_c0,vWhite,rsi4_1 < 50 ? bearishColor:bullishColor,'left',rsiTextSize)
            newTC(tBox, 3,5,str.format(" {0,number,#.##} ", rsi4_2),width_c0,vWhite,rsi4_2 < 50 ? bearishColor:bullishColor,'left',rsiTextSize)
//------------------------------------------------------
//--- Alerts -------------------------------------------
//------------------------------------------------------
RSI Bollinger Bands [DCAUT]█ RSI Bollinger Bands  
 📊 ORIGINALITY & INNOVATION 
The RSI Bollinger Bands indicator represents a meaningful advancement in momentum analysis by combining two proven technical tools: the Relative Strength Index (RSI) and Bollinger Bands. This combination addresses a significant limitation in traditional RSI analysis - the use of fixed overbought/oversold thresholds (typically 70/30) that fail to adapt to changing market volatility conditions.
 Core Innovation: 
Rather than relying on static threshold levels, this indicator applies Bollinger Bands statistical analysis directly to RSI values, creating dynamic zones that automatically adjust based on recent momentum volatility. This approach helps reduce false signals during low volatility periods while remaining sensitive to genuine extremes during high volatility conditions.
 Key Enhancements Over Traditional RSI: 
 
 Dynamic Thresholds: Overbought/oversold zones adapt to market conditions automatically, eliminating the need for manual threshold adjustments across different instruments and timeframes
 Volatility Context: Band width provides immediate visual feedback about momentum volatility, helping traders distinguish between stable trends and erratic movements
 Reduced False Signals: During ranging markets, narrower bands filter out minor RSI fluctuations that would trigger traditional fixed-threshold signals
 Breakout Preparation: Band squeeze patterns (similar to price-based BB) signal potential momentum regime changes before they occur
 Self-Referencing Analysis: By measuring RSI against its own statistical behavior rather than arbitrary levels, the indicator provides more relevant context
 
 📐 MATHEMATICAL FOUNDATION 
 Two-Stage Calculation Process: 
 Stage 1: RSI Calculation 
RSI = 100 - (100 / (1 + RS))
where RS = Average Gain / Average Loss over specified period
The RSI normalizes price momentum into a bounded 0-100 scale, making it ideal for statistical band analysis.
 Stage 2: Bollinger Bands on RSI 
Basis = MA(RSI, BB Length)
Upper Band = Basis + (StdDev(RSI, BB Length) × Multiplier)
Lower Band = Basis - (StdDev(RSI, BB Length) × Multiplier)
Band Width = Upper Band - Lower Band
The Bollinger Bands measure RSI's standard deviation from its own moving average, creating statistically-derived dynamic zones.
 Statistical Interpretation: 
 
 Under normal distribution assumptions with default 2.0 multiplier, approximately 95% of RSI values should fall within the bands
 Band touches represent statistically significant momentum extremes relative to recent behavior
 Band width expansion indicates increasing momentum volatility (strengthening trend or increasing uncertainty)
 Band width contraction signals momentum consolidation and potential regime change preparation
 
 📊 COMPREHENSIVE SIGNAL ANALYSIS 
 Visual Color Signals: 
This indicator features dynamic color fills that highlight extreme momentum conditions:
 Green Fill (Above Upper Band): 
 
 Appears when RSI breaks above the upper band, indicating exceptionally strong bullish momentum
 Represents dynamic overbought zone - not necessarily a reversal signal but a warning of extreme conditions
 In strong uptrends, green fills can persist as RSI "rides the band" - this indicates sustained momentum strength
 Exit of green zone (RSI falling back below upper band) often signals initial momentum weakening
 
 Red Fill (Below Lower Band): 
 
 Appears when RSI breaks below the lower band, indicating exceptionally weak bearish momentum
 Represents dynamic oversold zone - potential reversal or continuation signal depending on trend context
 In strong downtrends, red fills can persist as RSI "rides the band" - this indicates sustained selling pressure
 Exit of red zone (RSI rising back above lower band) often signals initial momentum recovery
 
 Position-Based Signals: 
 Upper Band Interactions: 
 
 RSI Touching Upper Band: Dynamic overbought condition - momentum is extremely strong relative to recent volatility, potential exhaustion or continuation depending on trend context
 RSI Riding Upper Band: Sustained strong momentum, often seen in powerful trends, not necessarily an immediate reversal signal but warrants monitoring for exhaustion
 RSI Crossing Below Upper Band: Initial momentum weakening signal, particularly significant if accompanied by price divergence
 
 Lower Band Interactions: 
 
 RSI Touching Lower Band: Dynamic oversold condition - momentum is extremely weak relative to recent volatility, potential reversal or continuation of downtrend
 RSI Riding Lower Band: Sustained weak momentum, common in strong downtrends, monitor for potential exhaustion
 RSI Crossing Above Lower Band: Initial momentum strengthening signal, early indication of potential reversal or consolidation
 
 Basis Line Signals: 
 
 RSI Above Basis: Bullish momentum regime - upward pressure dominant
 RSI Below Basis: Bearish momentum regime - downward pressure dominant
 Basis Crossovers: Momentum regime shifts, more significant when accompanied by band width changes
 RSI Oscillating Around Basis: Balanced momentum, often indicates ranging market conditions
 
 Volatility-Based Signals: 
 Band Width Patterns: 
 
 Narrow Bands (Squeeze): Momentum volatility compression, often precedes significant directional moves, similar to price coiling patterns
 Expanding Bands: Increasing momentum volatility, indicates trend acceleration or growing uncertainty
 Narrowest Band in 100 Bars: Extreme compression alert, high probability of upcoming volatility expansion
 
 Advanced Pattern Recognition: 
 Divergence Analysis: 
 
 Bullish Divergence: Price makes lower lows while RSI touches or stays above previous lower band touch, suggests downward momentum weakening
 Bearish Divergence: Price makes higher highs while RSI touches or stays below previous upper band touch, suggests upward momentum weakening
 Hidden Bullish: Price makes higher lows while RSI makes lower lows at the lower band, indicates strong underlying bullish momentum
 Hidden Bearish: Price makes lower highs while RSI makes higher highs at the upper band, indicates strong underlying bearish momentum
 
 Band Walk Patterns: 
 
 Upper Band Walk: RSI consistently touching or staying near upper band indicates exceptionally strong trend, wait for clear break below basis before considering reversal
 Lower Band Walk: RSI consistently at lower band signals very weak momentum, requires break above basis for reversal confirmation
 
 🎯 STRATEGIC APPLICATIONS 
 Strategy 1: Mean Reversion Trading 
 Setup Conditions: 
 
 Market Type: Ranging or choppy markets with no clear directional trend
 Timeframe: Works best on lower timeframes (5m-1H) or during consolidation phases
 Band Characteristic: Normal to narrow band width
 
 Entry Rules: 
 
 Long Entry: RSI touches or crosses below lower band, wait for RSI to start rising back toward basis before entry
 Short Entry: RSI touches or crosses above upper band, wait for RSI to start falling back toward basis before entry
 Confirmation: Use price action confirmation (candlestick reversal patterns) at band touches
 
 Exit Rules: 
 
 Target: RSI returns to basis line or opposite band
 Stop Loss: Fixed percentage or below recent swing low/high
 Time Stop: Exit if position not profitable within expected timeframe
 
 Strategy 2: Trend Continuation Trading 
 Setup Conditions: 
 
 Market Type: Clear trending market with higher highs/lower lows
 Timeframe: Medium to higher timeframes (1H-Daily)
 Band Characteristic: Expanding or wide bands indicating strong momentum
 
 Entry Rules: 
 
 Long Entry in Uptrend: Wait for RSI to pull back to basis line or slightly below, enter when RSI starts rising again
 Short Entry in Downtrend: Wait for RSI to rally to basis line or slightly above, enter when RSI starts falling again
 Avoid Counter-Trend: Do not fade RSI at bands during strong trends (band walk patterns)
 
 Exit Rules: 
 
 Trailing Stop: Move stop to break-even when RSI reaches opposite band
 Trend Break: Exit when RSI crosses basis against trend direction with conviction
 Band Squeeze: Reduce position size when bands start narrowing significantly
 
 Strategy 3: Breakout Preparation 
 Setup Conditions: 
 
 Market Type: Consolidating market after significant move or at key technical levels
 Timeframe: Any timeframe, but longer timeframes provide more reliable breakouts
 Band Characteristic: Narrowest band width in recent 100 bars (squeeze alert)
 
 Preparation Phase: 
 
 Identify band squeeze condition (bands at multi-period narrowest point)
 Monitor price action for consolidation patterns (triangles, rectangles, flags)
 Prepare bracket orders for both directions
 Wait for band expansion to begin
 
 Entry Execution: 
 
 Breakout Confirmation: Enter in direction of RSI band breakout (RSI breaks above upper band or below lower band)
 Price Confirmation: Ensure price also breaks corresponding technical level
 Volume Confirmation: Look for volume expansion supporting the breakout
 
 Risk Management: 
 
 Stop Loss: Place beyond consolidation pattern opposite extreme
 Position Sizing: Use smaller size due to false breakout risk
 Quick Exit: Exit immediately if RSI returns inside bands within 1-3 bars
 
 Strategy 4: Multi-Timeframe Analysis 
 Timeframe Selection: 
 
 Higher Timeframe: Daily or 4H for trend context
 Trading Timeframe: 1H or 15m for entry signals
 Confirmation Timeframe: 5m or 1m for precise entry timing
 
 Analysis Process: 
 
 Trend Identification: Check higher timeframe RSI position relative to bands, trade only in direction of higher timeframe momentum
 Setup Formation: Wait for trading timeframe RSI to show pullback to basis in trending direction
 Entry Timing: Use confirmation timeframe RSI band touch or crossover for precise entry
 Alignment Confirmation: All timeframes should show RSI moving in same direction for highest probability setups
 
 📋 DETAILED PARAMETER CONFIGURATION 
 RSI Source: 
 
 Close (Default): Standard price point, balances responsiveness and reliability
 HL2: Reduces noise from intrabar volatility, provides smoother RSI values
 HLC3 or OHLC4: Further smoothing for very choppy markets, slower to respond but more stable
 Volume-Weighted: Consider using VWAP or volume-weighted prices for additional liquidity context
 
 RSI Length Parameter: 
 
 Shorter Periods (5-10): More responsive but generates more signals, suitable for scalping or very active trading, higher noise level
 Standard (14): Default and most widely used setting, proven balance between responsiveness and reliability, recommended starting point
 Longer Periods (21-30): Smoother momentum measurement, fewer but potentially more reliable signals, better for swing trading or position trading
 Optimization Note: Test across different market regimes, optimal length often varies by instrument volatility characteristics
 
 RSI MA Type Parameter: 
 
 RMA (Default): Wilder's original smoothing method, provides traditional RSI behavior with balanced lag, most widely recognized and tested, recommended for standard technical analysis
 EMA: Exponential smoothing gives more weight to recent values, faster response to momentum changes, suitable for active trading and trending markets, reduces lag compared to RMA
 SMA: Simple average treats all periods equally, smoothest output with highest lag, best for filtering noise in choppy markets, useful for long-term position analysis
 WMA: Weighted average emphasizes recent data less aggressively than EMA, middle ground between SMA and EMA characteristics, balanced responsiveness for swing trading
 Advanced Options: Full access to 25+ moving average types including HMA (reduced lag), DEMA/TEMA (enhanced responsiveness), KAMA/FRAMA (adaptive behavior), T3 (smoothness), Kalman Filter (optimal estimation)
 Selection Guide: RMA for traditional analysis and backtesting consistency, EMA for faster signals in trending markets, SMA for stability in ranging markets, adaptive types (KAMA/FRAMA) for varying volatility regimes
 
 BB Length Parameter: 
 
 Short Length (10-15): Tighter bands that react quickly to RSI changes, more frequent band touches, suitable for active trading styles
 Standard (20): Balanced approach providing meaningful statistical context without excessive lag
 Long Length (30-50): Smoother bands that filter minor RSI fluctuations, captures only significant momentum extremes, fewer but higher quality signals
 Relationship to RSI Length: Consider BB Length greater than RSI Length for cleaner signals
 
 BB MA Type Parameter: 
 
 SMA (Default): Standard Bollinger Bands calculation using simple moving average for basis line, treats all periods equally, widely recognized and tested approach
 EMA: Exponential smoothing for basis line gives more weight to recent RSI values, creates more responsive bands that adapt faster to momentum changes, suitable for trending markets
 RMA: Wilder's smoothing provides consistent behavior aligned with traditional RSI when using RMA for both RSI and BB calculations
 WMA: Weighted average for basis line balances recent emphasis with historical context, middle ground between SMA and EMA responsiveness
 Advanced Options: Full access to 25+ moving average types for basis calculation, including HMA (reduced lag), DEMA/TEMA (enhanced responsiveness), KAMA/FRAMA (adaptive to volatility changes)
 Selection Guide: SMA for standard Bollinger Bands behavior and backtesting consistency, EMA for faster band adaptation in dynamic markets, matching RSI MA type creates unified smoothing behavior
 
 BB Multiplier Parameter: 
 
 Conservative (1.5-1.8): Tighter bands resulting in more frequent touches, useful in low volatility environments, higher signal frequency but potentially more false signals
 Standard (2.0): Default setting representing approximately 95% confidence interval under normal distribution, widely accepted statistical threshold
 Aggressive (2.5-3.0): Wider bands capturing only extreme momentum conditions, fewer but potentially more significant signals, reduces false signals in high volatility
 Adaptive Approach: Consider adjusting multiplier based on instrument characteristics, lower multiplier for stable instruments, higher for volatile instruments
 
 Parameter Optimization Workflow: 
 
 Start with default parameters (RSI:14, BB:20, Mult:2.0)
 Test across representative sample period including different market regimes
 Adjust RSI length based on desired responsiveness vs stability tradeoff
 Tune BB length to match your typical holding period
 Modify multiplier to achieve desired signal frequency
 Validate on out-of-sample data to avoid overfitting
 Document optimal parameters for different instruments and timeframes
 
 Reference Levels Display: 
 
 Enabled (Default): Shows traditional 30/50/70 levels for comparison with dynamic bands, helps visualize the adaptive advantage
 Disabled: Cleaner chart focusing purely on dynamic zones, reduces visual clutter for experienced users
 Educational Value: Keeping reference levels visible helps understand how dynamic bands differ from fixed thresholds across varying market conditions
 
 📈 PERFORMANCE ANALYSIS & COMPETITIVE ADVANTAGES 
 Comparison with Traditional RSI: 
 Fixed Threshold RSI Limitations: 
 
 In ranging low-volatility markets: RSI rarely reaches 70/30, missing tradable extremes
 In trending high-volatility markets: RSI frequently breaks through 70/30, generating excessive false reversal signals
 Across different instruments: Same thresholds applied to volatile crypto and stable forex pairs produce inconsistent results
 Threshold Adjustment Problem: Manually changing thresholds for different conditions is subjective and lagging
 
 RSI Bollinger Bands Advantages: 
 
 Automatic Adaptation: Bands adjust to current volatility regime without manual intervention
 Consistent Logic: Same statistical approach works across different instruments and timeframes
 Reduced False Signals: Band width filtering helps distinguish meaningful extremes from noise
 Additional Information: Band width provides volatility context missing in standard RSI
 Objective Extremes: Statistical basis (standard deviations) provides objective extreme definition
 
 Comparison with Price-Based Bollinger Bands: 
 Price BB Characteristics: 
 
 Measures absolute price volatility
 Affected by large price gaps and outliers
 Band position relative to price not normalized
 Difficult to compare across different price scales
 
 RSI BB Advantages: 
 
 Normalized Scale: RSI's 0-100 bounds make band interpretation consistent across all instruments
 Momentum Focus: Directly measures momentum extremes rather than price extremes
 Reduced Gap Impact: RSI calculation smooths price gaps impact on band calculations
 Comparable Analysis: Same RSI BB appearance across stocks, forex, crypto enables consistent strategy application
 
 Performance Characteristics: 
 Signal Quality: 
 
 Higher Signal-to-Noise Ratio: Dynamic bands help filter RSI oscillations that don't represent meaningful extremes
 Context-Aware Alerts: Band width provides volatility context helping traders adjust position sizing and stop placement
 Reduced Whipsaws: During consolidations, narrower bands prevent premature signals from minor RSI movements
 
 Responsiveness: 
 
 Adaptive Lag: Band calculation introduces some lag, but this lag is adaptive to current conditions rather than fixed
 Faster Than Manual Adjustment: Automatic band adjustment is faster than trader's ability to manually modify thresholds
 Balanced Approach: Combines RSI's inherent momentum lag with BB's statistical smoothing for stable yet responsive signals
 
 Versatility: 
 
 Multi-Strategy Application: Supports both mean reversion (ranging markets) and trend continuation (trending markets) approaches
 Universal Instrument Coverage: Works effectively across equities, forex, commodities, cryptocurrencies without parameter changes
 Timeframe Agnostic: Same interpretation applies from 1-minute charts to monthly charts
 
 Limitations and Considerations: 
 Known Limitations: 
 
 Dual Lag Effect: Combines RSI's momentum lag with BB's statistical lag, making it less suitable for very short-term scalping
 Requires Volatility History: Needs sufficient bars for BB calculation, less effective immediately after major regime changes
 Statistical Assumptions: Assumes RSI values are somewhat normally distributed, extreme trending conditions may violate this
 Not a Standalone System: Like all indicators, should be combined with price action analysis and risk management
 
 Optimal Use Cases: 
 
 Best for swing trading and position trading timeframes
 Most effective in markets with alternating volatility regimes
 Ideal for traders who use multiple instruments and timeframes
 Suitable for systematic trading approaches requiring consistent logic
 
 Suboptimal Conditions: 
 
 Very low timeframes (< 5 minutes) where lag becomes problematic
 Instruments with extreme volatility spikes (gap-prone markets)
 Markets in strong persistent trends where mean reversion rarely occurs
 Periods immediately following major structural changes (new trading regime)
 
 USAGE NOTES 
This indicator is designed for technical analysis and educational purposes to help traders understand the interaction between momentum measurement and statistical volatility bands. The RSI Bollinger Bands has limitations and should not be used as the sole basis for trading decisions.
 Important Considerations: 
 
 No Predictive Guarantee: Past band touches and patterns do not guarantee future price behavior
 Market Regime Dependency: Indicator performance varies significantly between trending and ranging market conditions
 Complementary Analysis Required: Should be used alongside price action, support/resistance levels, and fundamental analysis
 Risk Management Essential: Always use proper position sizing, stop losses, and risk controls regardless of signal quality
 Parameter Sensitivity: Different instruments and timeframes may require parameter optimization for optimal results
 Continuous Monitoring: Band characteristics change with market conditions, requiring ongoing assessment
 
 Recommended Supporting Analysis: 
 
 Price structure analysis (support/resistance, trend lines)
 Volume confirmation for breakout signals
 Multiple timeframe alignment
 Market context awareness (news events, session times)
 Correlation analysis with related instruments
 
The indicator aims to provide adaptive momentum analysis that adjusts to changing market volatility, but traders must apply sound judgment, proper risk management, and comprehensive market analysis in their decision-making process.






















