View compact source
//@version=5
indicator("Retail // Reset — EMA + RSI / MFI Context Combo", overlay=false)
// One TradingView slot: moving averages are forced onto price.
// RSI and MFI remain in this normal 0–100 lower pane.
src = input.source(close, "Moving-average source", group="General")
showRSI = input.bool(true, "Show RSI", group="Oscillators")
showMFI = input.bool(true, "Show MFI", group="Oscillators")
rsiLength = input.int(14, "RSI length", minval=1, group="Oscillators")
mfiLength = input.int(14, "MFI length", minval=1, group="Oscillators")
maValue(method, source, length) =>
method == "EMA" ? ta.ema(source, length) : ta.sma(source, length)
// MA 1 — default 20
ma1Method = input.string("EMA", "Method", options=["EMA", "SMA"], group="MA 1 · default 20")
ma1Length = input.int(20, "Length", minval=1, group="MA 1 · default 20")
ma1Color = input.color(color.aqua, "Colour", group="MA 1 · default 20")
ma1Opacity = input.int(0, "Opacity", minval=0, maxval=100, group="MA 1 · default 20")
ma1Width = input.int(2, "Thickness", minval=1, maxval=4, group="MA 1 · default 20")
ma1 = maValue(ma1Method, src, ma1Length)
// MA 2 — default 50
ma2Method = input.string("EMA", "Method", options=["EMA", "SMA"], group="MA 2 · default 50")
ma2Length = input.int(50, "Length", minval=1, group="MA 2 · default 50")
ma2Color = input.color(color.orange, "Colour", group="MA 2 · default 50")
ma2Opacity = input.int(0, "Opacity", minval=0, maxval=100, group="MA 2 · default 50")
ma2Width = input.int(2, "Thickness", minval=1, maxval=4, group="MA 2 · default 50")
ma2 = maValue(ma2Method, src, ma2Length)
// MA 3 — default 100
ma3Method = input.string("EMA", "Method", options=["EMA", "SMA"], group="MA 3 · default 100")
ma3Length = input.int(100, "Length", minval=1, group="MA 3 · default 100")
ma3Color = input.color(color.fuchsia, "Colour", group="MA 3 · default 100")
ma3Opacity = input.int(8, "Opacity", minval=0, maxval=100, group="MA 3 · default 100")
ma3Width = input.int(2, "Thickness", minval=1, maxval=4, group="MA 3 · default 100")
ma3 = maValue(ma3Method, src, ma3Length)
// MA 4 — default 200
ma4Method = input.string("EMA", "Method", options=["EMA", "SMA"], group="MA 4 · default 200")
ma4Length = input.int(200, "Length", minval=1, group="MA 4 · default 200")
ma4Color = input.color(color.yellow, "Colour", group="MA 4 · default 200")
ma4Opacity = input.int(12, "Opacity", minval=0, maxval=100, group="MA 4 · default 200")
ma4Width = input.int(2, "Thickness", minval=1, maxval=4, group="MA 4 · default 200")
ma4 = maValue(ma4Method, src, ma4Length)
plot(ma1, "MA 1", color=color.new(ma1Color, ma1Opacity), linewidth=ma1Width, force_overlay=true)
plot(ma2, "MA 2", color=color.new(ma2Color, ma2Opacity), linewidth=ma2Width, force_overlay=true)
plot(ma3, "MA 3", color=color.new(ma3Color, ma3Opacity), linewidth=ma3Width, force_overlay=true)
plot(ma4, "MA 4", color=color.new(ma4Color, ma4Opacity), linewidth=ma4Width, force_overlay=true)
rsi = ta.rsi(close, rsiLength)
mfi = ta.mfi(hlc3, mfiLength)
hline(70, "Upper guide", color=color.new(color.red, 50), linestyle=hline.style_dotted)
hline(50, "Midline", color=color.new(color.gray, 65), linestyle=hline.style_dotted)
hline(30, "Lower guide", color=color.new(color.lime, 50), linestyle=hline.style_dotted)
plot(showRSI ? rsi : na, "RSI", color=color.aqua, linewidth=2)
plot(showMFI ? mfi : na, "MFI", color=color.orange, linewidth=2)
// EMA = faster response to newer candles.
// SMA = equal weighting across the lookback.
// Read price, structure and volume together.