RSI Trend Veracity (RSI TV)
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © More-Than-Enough

//@version=5
indicator(title = "RSI Trend Veracity", shorttitle = "RSI TV", precision = 3, timeframe = "", timeframe_gaps = true)

Tv_Line = 0.0
Rsi_Line = ta.rsi(close, 14) * 0.1 - 5
Ma_Line = ta.sma(Rsi_Line, 14)

Low_Tsi = ta.tsi(close, 1, 54)
Low_Tv_Line = ta.rsi(close, 35) * 0.1 - 5 + Low_Tsi

High_Tsi = ta.tsi(close, 1, 13)
High_Tv_Line = ta.rsi(close, 35) * 0.1 - 5 + High_Tsi

if Rsi_Line > 0
    Tv_Line := High_Tv_Line
    
if Rsi_Line < 0
    Tv_Line := Low_Tv_Line

/////////////// Thresholds ///////////////

High_Extremity_Color = input.color(color.new(color.lime, 50), "High Extremity Color")
High_Extremity = input.float(3.0, "High Extremity", minval = 0.0, step = 0.1)

High_Color = input.color(color.new(color.lime, 50), "High Color")
High = input.float(2.0, "High", minval = 0.0, step = 0.1)

High_Mid_Color = input.color(color.gray, "High-Mid Color")

Mid = 0
Mid_Color = input.color(color.rgb(91, 156, 246, 50), "Middle Color")

Low_Mid_Color = input.color(color.gray, "Low-Mid Color")

Low = input.float(-2.0, "Low", maxval = 0.0, step = 0.1)
Low_Color = input.color(color.new(color.red, 50), "Low Color")

Low_Extremity = input.float(-3.0, "Low Extremity", maxval = 0.0, step = 0.1)
Low_Extremity_Color = input.color(color.new(color.red, 50), "Low Extremity Color")

/////////////// Plots ///////////////

High_Extremity_Line = hline(High_Extremity, "High Extremity Line", High_Extremity_Color, linestyle = hline.style_dotted, editable = false)

High_Line = hline(High, "High Line", High_Color, linestyle = hline.style_solid, editable = false)
High_Mid_Line = hline(Mid + ((math.abs(High) - math.abs(Mid)) / 2), "High-Mid Line", High_Mid_Color, linestyle = hline.style_dotted, editable = false)

Mid_Line = hline(Mid, "Middle Line", Mid_Color, linestyle = hline.style_solid, editable = false)

Low_Mid_Line = hline(Mid - ((math.abs(Mid) + math.abs(Low)) / 2), "Low-Mid Line", Low_Mid_Color, linestyle = hline.style_dotted, editable = false)
Low_Line = hline(Low, "Low Line", Low_Color, linestyle = hline.style_solid, editable = false)

Low_Extremity_Line = hline(Low_Extremity, "Low Extremity Line", Low_Extremity_Color, linestyle = hline.style_dotted, editable = false)

fill(Mid_Line, High_Line, color.rgb(129, 199, 132, 86), "Up Zone")
fill(Mid_Line, Low_Line, color.rgb(247, 124, 128, 86), "Down Zone")

plot(Tv_Line, "TV Plot", color = color.new(color.aqua, 50), style = plot.style_area)
plot(Ma_Line, "MA Plot", color = color.rgb(255, 245, 157), display = display.none)
plot(Rsi_Line, "RSI Plot", color = color.white)
