//@version=3 strategy(title="RK Trend Hunter", overlay=true) // Source input src = input(defval=close, title="Source") // Sampling Period per = input(defval=50, minval=1, title="Sampling Period") // Trend Multiplier (formerly Range Multiplier) mult = input(defval=10.0, minval=0.1, title="Trend Multiplier") // Smooth Trend Calculation (formerly Smooth Average Range) smoothTrend(x, t, m)=> wper = (t * 2) - 1 avrng = ema(abs(x - x[1]), t) smoothTrend = ema(avrng, wper) * m smoothTrend smTrend = smoothTrend(src, per, mult) // Trend Filter Calculation trendFilter(x, r)=> trendFilter = x trendFilter := x > nz(trendFilter[1]) ? ((x - r) < nz(trendFilter[1]) ? nz(trendFilter[1]) : (x - r)) : ((x + r) > nz(trendFilter[1]) ? nz(trendFilter[1]) : (x + r)) trendFilter filt = trendFilter(src, smTrend) // Filter Direction upward = 0.0 upward := filt > filt[1] ? nz(upward[1]) + 1 : filt < filt[1] ? 0 : nz(upward[1]) downward = 0.0 downward := filt < filt[1] ? nz(downward[1]) + 1 : filt > filt[1] ? 0 : nz(downward[1]) // Colors trendColor = upward > 0 ? lime : downward > 0 ? red : orange // === Neon Glow Effect === plot(filt, color=trendColor, linewidth=9, transp=90, title="Glow Outer") plot(filt, color=trendColor, linewidth=7, transp=80, title="Glow Mid") plot(filt, color=trendColor, linewidth=5, transp=70, title="Glow Inner") plot(filt, color=trendColor, linewidth=3, title="Trend Filter") // Main line // === Original Buy/Sell Signal Conditions === // Buy condition: Price crosses above the 'filt' line from below and the line is lime (upward trend) buySignal = crossover(src, filt) and trendColor == lime plotshape(buySignal, style=shape.labelup, location=location.belowbar, color=green, text="BUY", textcolor=white, size=size.small) // Sell condition: Price crosses below the 'filt' line from above and the line is red (downward trend) sellSignal = crossunder(src, filt) and trendColor == red plotshape(sellSignal, style=shape.labeldown, location=location.abovebar, color=red, text="SELL", textcolor=white, size=size.small) // === Additional Buy/Sell Conditions Based on Trend Color Change === // New Buy condition: Trend changes from downward (red) to upward (green) newBuySignal = trendColor == lime and trendColor[1] == red plotshape(newBuySignal, style=shape.labelup, location=location.belowbar, color=lime, text="STRONG", textcolor=white, size=size.small) // New Sell condition: Trend changes from upward (green) to downward (red) newSellSignal = trendColor == red and trendColor[1] == lime plotshape(newSellSignal, style=shape.labeldown, location=location.abovebar, color=maroon, text="STRONG", textcolor=white, size=size.small) // === Alert Conditions === alertcondition(buySignal, title="Buy Signal", message="Buy signal triggered") alertcondition(sellSignal, title="Sell Signal", message="Sell signal triggered") alertcondition(newBuySignal, title="Strong Buy Signal", message="Strong Buy signal triggered") alertcondition(newSellSignal, title="Strong Sell Signal", message="Strong Sell signal triggered")