RSI MTF Sequential Signal SME

RSI MTF Sequential Signal SME

//@version=5
indicator(title="RSI MTF Sequential Signal Arrows (Custom TF)-Sandesh Koli", shorttitle="RSI MTF Seq Arrow (Custom TF)-Sandesh Koli", overlay=false)

// === Inputs ===
rsiLength = input.int(14, title="RSI Length")
rsiSource = input.source(close, title="RSI Source")

// --- Custom Timeframe Inputs ---
lowerTimeframe = input.timeframe("5", title="Lower Timeframe (LTF)")
higherTimeframe = input.timeframe("60", title="Higher Timeframe (HTF)")

// --- Level Inputs ---
rsiLevel_HTF = input.float(40.0, title="HTF RSI Level (e.g., 40)")
rsiLevel_LTF = input.float(60.0, title="LTF RSI Level (e.g., 60)")

// === Calculations ===
rsi_LTF = request.security(syminfo.tickerid, lowerTimeframe, ta.rsi(rsiSource, rsiLength), barmerge.gaps_off, barmerge.lookahead_off)
rsi_HTF = request.security(syminfo.tickerid, higherTimeframe, ta.rsi(rsiSource, rsiLength), barmerge.gaps_off, barmerge.lookahead_off)

// === State Management ===
var bool htfConditionMet = false
if (ta.crossover(rsi_HTF, rsiLevel_HTF))
htfConditionMet := true
else if (ta.crossunder(rsi_HTF, rsiLevel_HTF))
htfConditionMet := false

// === Signal Condition ===
condition1_HTF_Active = htfConditionMet
condition2_LTF_Cross = ta.crossover(rsi_LTF, rsiLevel_LTF)
longSignalCondition = condition1_HTF_Active and condition2_LTF_Cross

// === Plotting ===

// --- Use Static Titles for Plots and Hlines ---
plot(rsi_LTF, "RSI LTF", color=color.new(color.blue, 0), linewidth=1)
hline(rsiLevel_LTF, "LTF Level", color=color.new(color.blue, 50), linestyle=hline.style_dashed)

plot(rsi_HTF, "RSI HTF", color=color.new(color.orange, 0), linewidth=2)
hline(rsiLevel_HTF, "HTF Level", color=color.new(color.orange, 50), linestyle=hline.style_dashed)

// Standard RSI levels
hline(70, "RSI Overbought (70)", color=color.new(color.red, 70), linestyle=hline.style_dotted)
hline(30, "RSI Oversold (30)", color=color.new(color.green, 70), linestyle=hline.style_dotted)
hline(50, "RSI Midline (50)", color=color.new(color.gray, 70), linestyle=hline.style_solid)

// === Signal Visualization ===
bgcolor(longSignalCondition ? color.new(color.green, 85) : na, title="Long Signal Background")
plotshape(longSignalCondition,
title="Long Signal Arrow",
location=location.bottom,
color=color.new(color.green, 0),
style=shape.arrowup,
size=size.small)

// === Alerts ===
// Alert message CAN use dynamic values from inputs
alertcondition(longSignalCondition, title="RSI MTF Seq Long Alert", message="{{ticker}}: HTF ({{input.timeframe_1}}) RSI > {{int(input.float_1)}} active, LTF ({{input.timeframe_0}}) RSI crossed {{int(input.float_2)}}")

Read More

Share:

Latest News