// Candle color detection (green = close > open, red = close < open) isGreenCandle = close > open isRedCandle = close < open
// Long Signal Logic: // 1. MACD Norm > Trigger // 2. RSI > SMA RSI // 3. First green candle closes above SMA longCondition = macdLongCondition and rsiLongCondition and isGreenCandle and close > sma var bool hasLongSignal = false // Tracks if a buy signal has been printed buySignal = longCondition and not hasLongSignal and not hasLongSignal[1] // Only first signal
if buySignal hasLongSignal := true // Mark that a buy signal has occurred if not macdLongCondition or not rsiLongCondition // Reset when conditions reverse hasLongSignal := false
// Short Signal Logic: // 1. MACD Norm < Trigger // 2. RSI < SMA RSI // 3. First red candle closes below SMA shortCondition = macdShortCondition and rsiShortCondition and isRedCandle and close < sma var bool hasShortSignal = false // Tracks if a sell signal has been printed sellSignal = shortCondition and not hasShortSignal and not hasShortSignal[1] // Only first signal
if sellSignal hasShortSignal := true // Mark that a sell signal has occurred if not macdShortCondition or not rsiShortCondition // Reset when conditions reverse hasShortSignal := false