These are my notes on debugging the open-source community-based technical indicator, RSI Long Only with Confirmed Cross-backs.
Issue
The script should be printing buy or sell signals.
//@version=6
strategy("(Debug) RSI Long Only with Confirmed Crossbacks", overlay=true)
// === Inputs ===
length = input(14, "RSI Length")
overSold = input(44, "RSI Buy Zone")
overBought = input(70, "RSI Sell Zone")
// === RSI Calculation ===
vrsi = ta.rsi(close, length)
// === Entry Logic ===
inOversold = vrsi < overSold
var bool oversoldTouched = false
if inOversold
oversoldTouched := true
entryCondition = oversoldTouched and (vrsi[1] < overSold and vrsi >= overSold)
if entryCondition
strategy.entry("RSI Long", strategy.long)
oversoldTouched := false // reset after entry
if entryCondition
label.new(bar_index, low, "ENTRY!", style=label.style_label_up, color=color.green)
// === Exit Logic ===
// Step 1: Wait for RSI to go above overbought threshold
inOverbought = vrsi > overBought
var bool overboughtTouched = false
if inOverbought
overboughtTouched := true
// Step 2: After RSI has gone above 75, wait for it to cross back below 75
exitCondition = overboughtTouched and ta.crossunder(vrsi, overBought)
if exitCondition
strategy.close("RSI Long")
overboughtTouched := false // reset after exit