Untitled

 avatar
unknown
plain_text
10 days ago
5.5 kB
6
Indexable
//@version=5
//Basic Hull Ma Pack tinkered by InSilico 
indicator('Hull Suite by InSilico', overlay=true)

//INPUT
src = input(close, title='Source')
modeSwitch = input.string('Hma', title='Hull Variation', options=['Hma', 'Thma', 'Ehma'])
length = input(55, 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.timeframe('240', title='Higher timeframe')

switchColor = input(true, 'Color Hull according to trend?')
candleCol = input(false, 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)

//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] ? #00ff00 : #ff0000 : #ff9800

// Sayım Sistemi için Değişkenler
var int HG = na
var int LW = na
var float last_high = na
var float last_low = na
var color last_color = na

// Trend rengini belirle
currentColor = HULL > HULL[2] ? color.green : color.red

// Renk değişikliğini kontrol et ve sayımları sıfırla
if (na(last_color) or (currentColor != last_color))
    HG := 1
    LW := 1
    last_high := high
    last_low := low
    last_color := currentColor
else
    // Renk değişimi olmadığında sayımları güncelle
    if (currentColor == color.green)
        if (high > last_high)
            HG := (HG < 9) ? (HG + 1) : 1
            last_high := high
    else
        if (low < last_low)
            LW := (LW < 9) ? (LW + 1) : 1
            last_low := low

//PLOT
///< Frame
Fi1 = plot(MHULL, title='MHULL', color=hullColor, linewidth=thicknesSwitch, transp=50)
Fi2 = plot(visualSwitch ? SHULL : na, title='SHULL', color=hullColor, linewidth=thicknesSwitch, transp=50)

///< Ending Filler
fill(Fi1, Fi2, title='Band Filler', color=hullColor, transp=transpSwitch)

// Sayım Numara Plotlama
plotshape(series=HG == 1 and HG[1] != 1, style=shape.triangledown, color=color.gray, text="1", textcolor=color.gray, location=location.abovebar)
plotshape(series=HG == 2 and HG[1] != 2, style=shape.triangledown, color=color.gray, text="2", textcolor=color.gray, location=location.abovebar)
plotshape(series=HG == 3 and HG[1] != 3, style=shape.triangledown, color=color.red, text="3", textcolor=color.red, location=location.abovebar)
plotshape(series=HG == 4 and HG[1] != 4, style=shape.triangledown, color=color.gray, text="4", textcolor=color.gray, location=location.abovebar)
plotshape(series=HG == 5 and HG[1] != 5, style=shape.triangledown, color=color.gray, text="5", textcolor=color.gray, location=location.abovebar)
plotshape(series=HG == 6 and HG[1] != 6, style=shape.triangledown, color=color.red, text="6", textcolor=color.red, location=location.abovebar)
plotshape(series=HG == 7 and HG[1] != 7, style=shape.triangledown, color=color.gray, text="7", textcolor=color.gray, location=location.abovebar)
plotshape(series=HG == 8 and HG[1] != 8, style=shape.triangledown, color=color.red, text="8", textcolor=color.red, location=location.abovebar)
plotshape(series=HG == 9 and HG[1] != 9, style=shape.triangledown, color=color.red, text="9", textcolor=color.red, location=location.abovebar)

plotshape(series=LW == 1 and LW[1] != 1, style=shape.triangleup, color=color.gray, text="1", textcolor=color.gray, location=location.belowbar)
plotshape(series=LW == 2 and LW[1] != 2, style=shape.triangleup, color=color.gray, text="2", textcolor=color.gray, location=location.belowbar)
plotshape(series=LW == 3 and LW[1] != 3, style=shape.triangleup, color=color.green, text="3", textcolor=color.green, location=location.belowbar)
plotshape(series=LW == 4 and LW[1] != 4, style=shape.triangleup, color=color.gray, text="4", textcolor=color.gray, location=location.belowbar)
plotshape(series=LW == 5 and LW[1] != 5, style=shape.triangleup, color=color.gray, text="5", textcolor=color.gray, location=location.belowbar)
plotshape(series=LW == 6 and LW[1] != 6, style=shape.triangleup, color=color.green, text="6", textcolor=color.green, location=location.belowbar)
plotshape(series=LW == 7 and LW[1] != 7, style=shape.triangleup, color=color.gray, text="7", textcolor=color.gray, location=location.belowbar)
plotshape(series=LW == 8 and LW[1] != 8, style=shape.triangleup, color=color.green, text="8", textcolor=color.green, location=location.belowbar)
plotshape(series=LW == 9 and LW[1] != 9, style=shape.triangleup, color=color.green, text="9", textcolor=color.green, location=location.belowbar)
Editor is loading...
Leave a Comment