OPEN-SOURCE SCRIPT

Hull MA Crossover Band

Telah dikemas kini
//version=5
indicator("Hull MA Crossover Band", overlay=true)

// Inputs
src = input.source(close, title="Source")
length = input.int(55, title="Hull MA Length")
smoothing = input.int(3, title="Smoothing Length") // Additional smoothing to narrow bandwidth

// Function: Hull Moving Average (HMA) Calculation
HMA(_src, _length) =>
ta.wma(2 * ta.wma(_src, _length / 2) - ta.wma(_src, _length), math.round(math.sqrt(_length)))

// Calculate Hull MA with additional smoothing
hullMA = HMA(src, length)
smoothedHullMA = ta.sma(hullMA, smoothing) // Applying extra smoothing for stability

// Define color based on position of candle relative to the Hull MA
hullColor = close > smoothedHullMA ? color.green : color.red

// Plot the Hull MA band with color indicating position of price
plot(smoothedHullMA, color=hullColor, linewidth=2, title="Hull MA Band")
Nota Keluaran
//version=5
indicator("Hull MA Crossover Band with Buy/Sell Signals", overlay=true)

// Inputs
src = input.source(close, title="Source")
length = input.int(55, title="Hull MA Length")
smoothing = input.int(3, title="Smoothing Length") // Additional smoothing to narrow bandwidth

// Function: Hull Moving Average (HMA) Calculation
HMA(_src, _length) =>
ta.wma(2 * ta.wma(_src, _length / 2) - ta.wma(_src, _length), math.round(math.sqrt(_length)))

// Calculate Hull MA with additional smoothing
hullMA = HMA(src, length)
smoothedHullMA = ta.sma(hullMA, smoothing) // Applying extra smoothing for stability

// Define color based on position of candle relative to the Hull MA
hullColor = close > smoothedHullMA ? color.green : color.red

// Plot the Hull MA band with color indicating position of price
plot(smoothedHullMA, color=hullColor, linewidth=2, title="Hull MA Band")

// Buy and Sell Signal Conditions
buyCondition = ta.crossover(hl2, smoothedHullMA) // Buy when Heikin Ashi midpoint crosses above smoothed HMA
sellCondition = ta.crossunder(hl2, smoothedHullMA) // Sell when Heikin Ashi midpoint crosses below smoothed HMA

// Plot Buy and Sell Labels
plotshape(series=buyCondition, location=location.belowbar, color=color.green, style=shape.labelup, text="BUY", title="Buy Signal")
plotshape(series=sellCondition, location=location.abovebar, color=color.red, style=shape.labeldown, text="SELL", title="Sell Signal")

// Alerts for Buy and Sell Signals
alertcondition(buyCondition, title="Buy Alert", message="Buy Signal: Hull MA Crossover")
alertcondition(sellCondition, title="Sell Alert", message="Sell Signal: Hull MA Crossover")
Bands and Channels

Skrip sumber terbuka

Dalam semangat sebenar TradingView, penulis telah menerbitkan kod Pine ini sebagai sumber terbuka supaya pedagang dapat memahami dan mengesahkannya. Sorakan kepada penulis! Anda boleh menggunakan perpustakaan ini secara percuma, tetapi penggunaan semula kod dalam penerbitan ini adalah dikawal oleh Peraturan dalaman. Anda boleh menyukainya untuk menggunakannya pada carta.

Ingin menggunakan skrip ini pada carta?

Penafian