Review Entire Code and Fix the Code, Error at 112:15 Mismatched input ',' expecting ')' Code: //@version=5
indicator("Multi Time Frame Trend Detector", overlay=true)

// === User Inputs ===

// Time Frame Inputs
higher_tf = input.timeframe("D", "Higher Time Frame")
intermediate_tf = input.timeframe("60", "Intermediate Time Frame")

// Time Frame Enable Inputs
htf_enabled = input.bool(true, "Show Higher Time Frame Trend")
itf_enabled = input.bool(true, "Show Intermediate Time Frame Trend")

// Pivot Parameters
pivot_left = input.int(5, "Pivot Left Bars", minval=1)
pivot_right = input.int(5, "Pivot Right Bars", minval=1)

// Moving Average Length
ma_length = input.int(21, "MA Length")

// === Time Frame Data Retrieval ===

// Retrieve data unconditionally
htf_high = request.security(syminfo.tickerid, higher_tf, high)
htf_low = request.security(syminfo.tickerid, higher_tf, low)
htf_close = request.security(syminfo.tickerid, higher_tf, close)

itf_high = request.security(syminfo.tickerid, intermediate_tf, high)
itf_low = request.security(syminfo.tickerid, intermediate_tf, low)
itf_close = request.security(syminfo.tickerid, intermediate_tf, close)

// === Pivot Point Detection ===

// Initialize variables with explicit types
float htf_pivot_high = na
float htf_pivot_low = na
float htf_pivot_high_shifted = na
float htf_pivot_low_shifted = na
float htf_close_shifted = na

float itf_pivot_high = na
float itf_pivot_low = na
float itf_pivot_high_shifted = na
float itf_pivot_low_shifted = na
float itf_close_shifted = na

// Calculate pivots and shifted values when enabled
if htf_enabled
    htf_pivot_high := ta.pivothigh(htf_high, pivot_left, pivot_right)
    htf_pivot_low := ta.pivotlow(htf_low, pivot_left, pivot_right)
    htf_pivot_high_shifted := htf_pivot_high[pivot_right]
    htf_pivot_low_shifted := htf_pivot_low[pivot_right]
    htf_close_shifted := htf_close[pivot_right]

if itf_enabled
    itf_pivot_high := ta.pivothigh(itf_high, pivot_left, pivot_right)
    itf_pivot_low := ta.pivotlow(itf_low, pivot_left, pivot_right)
    itf_pivot_high_shifted := itf_pivot_high[pivot_right]
    itf_pivot_low_shifted := itf_pivot_low[pivot_right]
    itf_close_shifted := itf_close[pivot_right]

// === Moving Averages ===

float htf_ma = na
float htf_ma_shifted = na
if htf_enabled
    htf_ma := ta.sma(htf_close, ma_length)
    htf_ma_shifted := htf_ma[pivot_right]

float itf_ma = na
float itf_ma_shifted = na
if itf_enabled
    itf_ma := ta.sma(itf_close, ma_length)
    itf_ma_shifted := itf_ma[pivot_right]

// === Trend Determination ===

string htf_trend = ""
if htf_enabled
    if not na(htf_pivot_high_shifted)
        htf_trend := "Downtrend"
    else if not na(htf_pivot_low_shifted)
        htf_trend := "Uptrend"
    else
        htf_trend := na(htf_trend[1]) ? "Sideways" : htf_trend[1]
    if htf_close_shifted > htf_ma_shifted
        htf_trend := htf_trend == "Downtrend" ? "Sideways" : "Uptrend"
    else
        htf_trend := htf_trend == "Uptrend" ? "Sideways" : "Downtrend"

string itf_trend = ""
if itf_enabled
    if not na(itf_pivot_high_shifted)
        itf_trend := "Downtrend"
    else if not na(itf_pivot_low_shifted)
        itf_trend := "Uptrend"
    else
        itf_trend := na(itf_trend[1]) ? "Sideways" : itf_trend[1]
    if itf_close_shifted > itf_ma_shifted
        itf_trend := itf_trend == "Downtrend" ? "Sideways" : "Uptrend"
    else
        itf_trend := itf_trend == "Uptrend" ? "Sideways" : "Downtrend"

// === Trend Table Display ===

// Create a table with up to 2 rows
var table trend_table = table.new(position.top_right, 1, 2, border_width=1)

// Get table dimensions
int table_columns = na
int table_rows = na
(table_columns, table_rows) = table.get_dimensions(trend_table)

// Clear the table at each bar to prevent overlapping cells
table.clear(trend_table, 0, 0, table_columns, table_rows)

// Default Trend Table Colors
color htf_trend_up_color_default = color.new(color.green, 70)
color htf_trend_down_color_default = color.new(color.red, 70)
color htf_trend_sideways_color_default = color.new(color.orange, 70)

color itf_trend_up_color_default = color.new(color.green, 70)
color itf_trend_down_color_default = color.new(color.red, 70)
color itf_trend_sideways_color_default = color.new(color.orange, 70)

// Update the table cells based on enabled trends
int currentRow = 0

if htf_enabled
    color htf_bgcolor = htf_trend == "Uptrend" ? htf_trend_up_color_default :
                        htf_trend == "Downtrend" ? htf_trend_down_color_default :
                        htf_trend_sideways_color_default
    table.cell(trend_table, 0, currentRow, "HTF Trend: " + htf_trend, text_color=color.white, bgcolor=htf_bgcolor)
    currentRow += 1

if itf_enabled
    color itf_bgcolor = itf_trend == "Uptrend" ? itf_trend_up_color_default :
                        itf_trend == "Downtrend" ? itf_trend_down_color_default :
                        itf_trend_sideways_color_default
    table.cell(trend_table, 0, currentRow, "ITF Trend: " + itf_trend, text_color=color.white, bgcolor=itf_bgcolor)
    currentRow += 1

// === Pivot Plotting Management ===

// Default pivot plot styles
color htf_pivot_high_color_default = color.red
color htf_pivot_low_color_default = color.lime
color itf_pivot_high_color_default = color.purple
color itf_pivot_low_color_default = color.yellow
pivot_shape_size = size.tiny

// Plot pivot points for HTF
htf_pivot_high_plot = htf_enabled and not na(htf_pivot_high_shifted) ? htf_high[pivot_right * 2] : na
plotshape(htf_pivot_high_plot, title="HTF Pivot High", style=shape.triangledown, location=location.absolute, color=htf_pivot_high_color_default, size=pivot_shape_size, offset=-pivot_right * 2)

htf_pivot_low_plot = htf_enabled and not na(htf_pivot_low_shifted) ? htf_low[pivot_right * 2] : na
plotshape(htf_pivot_low_plot, title="HTF Pivot Low", style=shape.triangleup, location=location.absolute, color=htf_pivot_low_color_default, size=pivot_shape_size, offset=-pivot_right * 2)

// Plot pivot points for ITF
itf_pivot_high_plot = itf_enabled and not na(itf_pivot_high_shifted) ? itf_high[pivot_right * 2] : na
plotshape(itf_pivot_high_plot, title="ITF Pivot High", style=shape.triangledown, location=location.absolute, color=itf_pivot_high_color_default, size=pivot_shape_size, offset=-pivot_right * 2)

itf_pivot_low_plot = itf_enabled and not na(itf_pivot_low_shifted) ? itf_low[pivot_right * 2] : na
plotshape(itf_pivot_low_plot, title="ITF Pivot Low", style=shape.triangleup, location=location.absolute, color=itf_pivot_low_color_default, size=pivot_shape_size, offset=-pivot_right * 2)

// === Moving Averages Plotting ===

// Plot the moving averages only if enabled
htf_ma_plot = htf_enabled ? htf_ma : na
plot(htf_ma_plot, title="HTF MA", color=color.blue)

itf_ma_plot = itf_enabled ? itf_ma : na
plot(itf_ma_plot, title="ITF MA", color=color.orange)