Skip to content

Instantly share code, notes, and snippets.

@HoraceBury
Created July 20, 2025 10:02
Show Gist options
  • Select an option

  • Save HoraceBury/a0c13bfc2f19007f0513bcd2579bde7f to your computer and use it in GitHub Desktop.

Select an option

Save HoraceBury/a0c13bfc2f19007f0513bcd2579bde7f to your computer and use it in GitHub Desktop.
RSI 4-Candle Reversal
//@version=6
indicator("RSI 4-Candle Reversal", overlay=true)
// Strategy Idea: Enter at close of signal candle, SL at previous high/low and TP at 1:2 RR
// === INPUTS ===
rsiLength = input.int(14, title="RSI Length")
rsiSource = input.source(close, title="RSI Source")
highlightBullish = input.bool(true, title="Highlight Bullish Pattern")
highlightBearish = input.bool(true, title="Highlight Bearish Pattern")
// === RSI CALCULATION ===
rsi = ta.rsi(rsiSource, rsiLength)
// === PATTERN LOGIC ===
rsi_1 = rsi[3]
rsi_2 = rsi[2]
rsi_3 = rsi[1]
rsi_4 = rsi
// Bullish Pattern Conditions
bullishPattern =
rsi_1 < 30 and
rsi_2 > 40 and
rsi_3 >= 30 and rsi_3 <= 40 and
rsi_4 > rsi_2 + 1.5
// Bearish Pattern Conditions
bearishPattern =
rsi_1 > 70 and
rsi_2 < 60 and
rsi_3 >= 60 and rsi_3 <= 70 and
rsi_4 < rsi_2 - 1.5
if bearishPattern
log.info("bear")
if bullishPattern
log.info("bull")
// === BACKGROUND COLOUR ===
bgcolor(highlightBullish and bullishPattern ? color.new(color.green, 85) : na)
bgcolor(highlightBearish and bearishPattern ? color.new(color.red, 85) : na)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment