pine-scriptpine-script-v5tradingpine-script-v4

Rate of Change of Hull Moving Average Indicator for TradingView


I'm new to Pine Editor. Can anyone help me write a code for Rate of Change of Hull Moving Average Indicator for TradingView ? Its a very useful indicator. Thx


Solution

  • You can combine built-in hull moving average and roc function as in the example below

    // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
    // © e2e4mfck
    
    //@version=4
    study("Rate of Hull Change", overlay = false)
    
    // Inputs
    i_hullLength    = input(9, "Hull Length", minval=1)
    i_rocLength     = input(1, "Rate of Change Length", minval=1)
    i_src           = input(close, title="Source")
    
    hullma  = wma(2*wma(i_src, i_hullLength/2)-wma(i_src, i_hullLength), round(sqrt(i_hullLength)))
    rocHull = roc(hullma, i_rocLength)
    
    plot(rocHull)