Files
xPineScript/xIndicators/x-saherelm.hull.trend.pine
T
2024-01-25 04:07:49 +03:30

84 lines
2.2 KiB
Plaintext

///////////////////////////////////////////////////////
//
// SaherElm IT Center Hull Trend Indicator
// ---------------------------------------------
// saherelm implementation of above indicator ...
//
// Maintainer:
// ------------
// Hadi Khazaee Asl (hadi_khazaee_asl@yahoo.com)
//
//////////////////////////////////////////////////////
//
//@version=5
indicator(title="SaherElm Hull Trend Indicator", shorttitle = "XS_HUTR_IND", overlay = true)
//
// START Inputs ....
//
HUTRSrc = input.source(defval = hl2, title = "Source")
HUTRLength = input.int(defval = 23, title = "Length")
HUTRShowCross = input.bool(defval = true, title = "Show cross over/under")
//
// END Inputs ....
//
//
// START Functions ....
//
//
HUTRHma(src, length)=>
ta.wma((2 * ta.wma(src, length / 2)) - ta.wma(src, length), math.round(math.sqrt(length)))
//
HUTRHma3(src, length)=>
p = length / 2
ta.wma(ta.wma(close, p / 3) * 3 - ta.wma(close, p / 2) - ta.wma(close, p) ,p)
//
// END Functions ....
//
//
// START Calculations ....
//
//
HUTRA = HUTRHma(HUTRSrc, HUTRLength)
HUTRB = HUTRHma3(HUTRSrc, HUTRLength)
HUTRColor = HUTRB > HUTRA ? color.lime : color.red
//
HUTRCrossDown = HUTRA > HUTRB and HUTRA[1] < HUTRB[1]
HUTRCrossUp = HUTRB > HUTRA and HUTRB[1] < HUTRA[1]
//
// END Calculations ....
//
//
// START Plots ....
//
HUTRP1 = plot(series = HUTRA, color = color.new(HUTRColor, 75), linewidth = 1, title = "Upper Line")
HUTRP2 = plot(series = HUTRB, color = color.new(HUTRColor, 75), linewidth = 1, title = "Downer Line")
//
fill(HUTRP1, HUTRP2, color = color.new(HUTRColor, 55), title = "Cloud Fill")
//
plotshape(HUTRShowCross and HUTRCrossDown ? HUTRA : na, location = location.absolute, style = shape.labeldown, color = color.red, size = size.tiny, text = "Sell", textcolor = color.white, offset=-1)
plotshape(HUTRShowCross and HUTRCrossUp ? HUTRA : na, location = location.absolute, style = shape.labelup, color = color.green, size = size.tiny, text = "Buy", textcolor = color.white, offset=-1)
//
// END Plots ....
//
//
// START Alerts ...
//
// END Alerts ...
//
//////////////////////////////////////////////////////
// TODOS:
// -------
// - []
//////////////////////////////////////////////////////