//@version=5
indicator("Tether Line crossFixed", overlay=true)

// Input settings
useFixedValue = input.bool(false, title="Fixed Value")
assetType = input.string("forex", title="Asset Type", options=["forex", "crypto", "stocks", "metals"])
timeFrame = input.string("4h", title="Time Frame", options=["4h", "1d"])

// Default Length input
userLength = input.int(50, minval=1, title="Length")

// Determine Length based on Fixed Value setting
var Length = userLength

if useFixedValue
    if assetType == "forex" and timeFrame == "4h"
        Length := 87
    else if assetType == "forex" and timeFrame == "1d"
        Length := 30
    else if assetType == "crypto" and timeFrame == "4h"
        Length := 55
    else if assetType == "crypto" and timeFrame == "1d"
        Length := 48
    else if assetType == "metals" and timeFrame == "4h"
        Length := 96
    else if assetType == "metals" and timeFrame == "1d"
        Length := 37
    else if assetType == "stocks" and timeFrame == "4h"
        Length := 43
    else if assetType == "stocks" and timeFrame == "1d"
        Length := 98

// Tether Line Calculation
lower = ta.lowest(Length)
upper = ta.highest(Length)
xTether = (upper + lower) / 2

// Plotting the Tether Line
plot(xTether, color=color.yellow, title="Tether", linewidth = 2)

// Crossover/Crossunder conditions for price and Tether Line
priceCrossAbove = ta.crossover(close, xTether)
priceCrossBelow = ta.crossunder(close, xTether)

// Plot shapes on the bottom based on price crossing the Tether Line
plotshape(priceCrossAbove, title="tether CO", location=location.bottom, style=shape.triangleup, size=size.tiny, color=color.green)
plotshape(priceCrossBelow, title="tether CU", location=location.bottom, style=shape.triangledown, size=size.tiny, color=color.red)