این کد اندیکاتور را تبدیل به دو تا بکن
//@version=5
// Indicator title on TradingView
indicator("RSI with Overbought/Oversold Signals", shorttitle="RSI Signals", overlay=false)
// -----------------------------------------------------------------------------
// Customizable User Inputs
// -----------------------------------------------------------------------------
// RSI period length (usually 14)
int rsiLength = input.int(14, title="RSI Length", minval=1)
// Overbought level (usually 70)
float obLevel = input.float(70.0, title="Overbought Level", minval=0, maxval=100)
// Oversold level (usually 30)
float osLevel = input.float(30.0, title="Oversold Level", minval=0, maxval=100)
// Background colors for Overbought/Oversold areas
varip color obColor = input.color(color.red, "Overbought Zone Color")
varip color osColor = input.color(color.green, "Oversold Zone Color")
// -----------------------------------------------------------------------------
// Indicator Calculations
// -----------------------------------------------------------------------------
// Calculate RSI value based on closing price (close) and specified period length
float rsiValue = ta.rsi(close, rsiLength)
// -----------------------------------------------------------------------------
// Plotting the Indicator and Levels
// -----------------------------------------------------------------------------
// Plot the RSI line
plot(rsiValue, "RSI", color.blue, linewidth=2)
// Plot horizontal lines for Overbought, Oversold, and the 50 middle line
hline(obLevel, "Overbought Level", color.red, linestyle=hline.style_solid)
hline(osLevel, "Oversold Level", color.green, linestyle=hline.style_solid)
hline(50, "Mid-Line (50)", color.gray, linestyle=hline.style_dashed)
// -----------------------------------------------------------------------------
// Background Coloring for Overbought and Oversold regions
// -----------------------------------------------------------------------------
// If RSI is above the Overbought level, change the background to a light red color
bgcolor(rsiValue > obLevel ? color.new(obColor, 90) : na, title="Overbought Zone")
// If RSI is below the Oversold level, change the background to a light green color
bgcolor(rsiValue < osLevel ? color.new(osColor, 90) : na, title="Oversold Zone")
// -----------------------------------------------------------------------------
// Generating Buy/Sell Signals (Crossovers)
// -----------------------------------------------------------------------------
// Buy Signal: When RSI crosses the Oversold level from below
bool crossUpOS = ta.crossover(rsiValue, osLevel)
// Sell Signal: When RSI crosses the Overbought level from above
bool crossDownOB = ta.crossunder(rsiValue, obLevel)
// -----------------------------------------------------------------------------
// Plotting Shapes for Signals on the Main Chart
// -----------------------------------------------------------------------------
// Plot an upward triangle (green) below the bars for a Buy signal
plotshape(crossUpOS, title="RSI Buy Signal (Oversold Crossover)", location=location.belowbar, color=color.green, style=shape.triangleup, size=size.small, text="Buy")
// Plot a downward triangle (red) above the bars for a Sell signal
plotshape(crossDownOB, title="RSI Sell Signal (Overbought Crossover)", location=location.abovebar, color=color.red, style=shape.triangledown, size=size.small, text="Sell")
// -----------------------------------------------------------------------------
// Defining Alert Conditions for TradingView
// -----------------------------------------------------------------------------
// Alert for a Buy signal
alertcondition(crossUpOS, title="RSI Buy Alert", message="RSI crossed above Oversold level ({{osLevel}}). Potential Buy!")
// Alert for a Sell signal
alertcondition(crossDownOB, title="RSI Sell Alert", message="RSI crossed below Overbought level ({{obLevel}}). Potential Sell!")