Rally HTF Candle  (Candlestick Analysis) Guaranteed Winners
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © MINTYFRESH97

//@version=5
indicator("Rally D/6h Candle" ,overlay=true )

//user input
var g_ema    = "EMA Filter"
emaLength    = input.int(title="EMA Length", defval=100, tooltip="Length of the EMA filter", group=g_ema)
useEmaFilter = input.bool(title="Use EMA Filter?", defval=false, tooltip="Turns on/off the EMA filter", group=g_ema)

// Get EMA filter
ema = ta.ema(close, emaLength)
emaFilterLong = not useEmaFilter or close > ema
emaFilterShort = not useEmaFilter or close < ema


//////rallycandledaily

//swing high/low filter
swingHigh = high == ta.highest(high,5) or high[1] == ta.highest(high,5)

RallieCandle = (close[2] > close[3]) and (close[1] > close[2]) and
     (close < close[1]) and emaFilterShort and swingHigh and timeframe.isdaily
     
///////rallycandle6h

//swing high/low filter
swingHighx = high == ta.highest(high,8) or high[1] == ta.highest(high,8)

RallieCandle6h = (close[3] > close[4]) and (close[2] > close[23]) and
     (close < close[1]) and emaFilterShort and swingHigh 
     



// Plot our candle patterns
plotshape(RallieCandle, style=shape.xcross,size=size.tiny, color=color.red, text="R",location=location.abovebar)
barcolor (RallieCandle ? color.purple :na)
alertcondition(RallieCandle, "RallieCandle", "RallieCandle detected for {{ticker}}")

// Plot our candle patterns
plotshape(RallieCandle6h, style=shape.xcross,size=size.tiny, color=color.red, text="R",location=location.abovebar)
barcolor (RallieCandle6h ? color.purple :na)
alertcondition(RallieCandle6h, "RallieCandle", "RallieCandle detected for {{ticker}}")
