//INPUT showHullHTF = input.bool('true', "Show Hull HTF?") show_mhull = timeframe.multiplier <= 60 and timeframe.isminutes ? true : false show_shull = show_mhull ? true : false src = input(close, title="Source") modeSwitch = input.string("Hma", title="Hull Variation", options=["Hma", "Thma", "Ehma"]) int chartTFInMinutes = timeframe.in_seconds() / 60 tf_minute = timeframe.isminutes ? true : false tf_hour = tf_minute ? timeframe.multiplier == 60 ? true : false : false tf15min = timeframe.isminutes and timeframe.multiplier == 15 ? true : false tf30min = tf_minute ? timeframe.multiplier == 30 ? true : false : false tf1h = timeframe.isminutes and timeframe.multiplier == 60 ? true : false //length = chartTFInMinutes >= 30 ? 24 : chartTFInMinutes >= 60 ? 15 : 0 //// length=20 is good in a 1H chart length := input.int(20, title="Length(180-200 for floating S/R , 55 for swing entry)") lengthMult = input(1.0, title="Length multiplier (Used to view higher timeframes with straight band)") useHtf = input(false, title="Show Hull MA from X timeframe? (good for scalping)") htf = input("120", title="Higher timeframe") //htf = input("240", title="Higher timeframe", type=input.resolution) switchColor = input(true, "Color Hull according to trend?") candleCol = input(true,title="Color candles based on Hull's Trend?") visualSwitch = input(true, title="Show as a Band?") thicknesSwitch = input(1, title="Line Thickness") transpSwitch = input.int(40, title="Band Transparency",step=5) bgcol_hullcol = input(false, "Bg color will be Hull color?") //// Colors //// hull_bullish = input.color(color.rgb(52, 160, 248, 70)) hull_bearish = input.color(color.rgb(246, 135, 191, 70)) candle_bullish = input.color(color.rgb(0, 153, 51)) candle_bearish = input.color(color.rgb(255, 51, 0)) //FUNCTIONS //HMA HMA(_src, _length) => ta.wma(2 * ta.wma(_src, _length / 2) - ta.wma(_src, _length), math.round(math.sqrt(_length))) //EHMA EHMA(_src, _length) => ta.ema(2 * ta.ema(_src, _length / 2) - ta.ema(_src, _length), math.round(math.sqrt(_length))) //THMA THMA(_src, _length) => ta.wma(ta.wma(_src,_length / 3) * 3 - ta.wma(_src, _length / 2) - ta.wma(_src, _length), _length) //SWITCH Mode(modeSwitch, src, len) => modeSwitch == "Hma" ? HMA(src, len) : modeSwitch == "Ehma" ? EHMA(src, len) : modeSwitch == "Thma" ? THMA(src, len/2) : na //OUT _hull = Mode(modeSwitch, src, int(length * lengthMult)) HULL = useHtf ? request.security(syminfo.ticker, htf, _hull) : _hull MHULL = HULL[0] SHULL = HULL[2] //COLOR hullColor = switchColor ? (HULL > HULL[2] ? hull_bullish : hull_bearish ) : #000000 //// Candle color col_candle_hull = (HULL > HULL[2] ? candle_bullish : candle_bearish ) //// Background color according to Hull color bgcolor(bgcol_hullcol ? HULL > HULL[2] ? hull_bullish : hull_bearish : na) //PLOT ///< Frame Fi1 = plot(show_mhull ? MHULL : na, title="MHULL", color=hullColor, linewidth=thicknesSwitch) Fi2 = plot(show_shull ? SHULL : na, title="SHULL", color=hullColor, linewidth=thicknesSwitch) alertcondition(ta.crossover(MHULL, SHULL), title="Hull trending up.", message="Hull trending up.") alertcondition(ta.crossover(SHULL, MHULL), title="Hull trending down.", message="Hull trending down.") ///< Ending Filler fill(Fi1, Fi2, title="Band Filler", color=hullColor) ///BARCOLOR barcolor(color = candleCol ? (switchColor and timeframe.multiplier <= 60 ? col_candle_hull : na) : na)