W and M Pattern Indicator- SwaG
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © swagato25

//@version=5
indicator("W and M Pattern Indicator- SwaG", overlay=true)

//Inputs
upper_limit = input.int(defval = 70, title = "Upper Limit")
lower_limit = input.int(defval = 40, title = "Lower Limit")

// Get the RSI values
rsi = ta.rsi(close, 50)

// Calculate the W and M patterns
w_pattern = ( rsi<rsi[1] and rsi[10]>rsi[22] and rsi[2] < lower_limit )
m_pattern = ( rsi>rsi[9] and rsi[1]<rsi[5] and rsi[7] > upper_limit )

plotshape(w_pattern, style=shape.triangleup, location=location.belowbar, color=color.green, size=size.small)
plotshape(m_pattern, style=shape.triangledown, location=location.abovebar, color=color.red, size=size.small)