TradingView
SeaSide420
27 Th01 2019 02:11

Hull Moving Average and TSI 

Bitcoin / US Dollar Perpetual Inverse Swap ContractBitMEX

Mô tả

HMA crossover & TSI crossover
Bình luận
Feelax
Dear seadide,
Can you help me extract add one more below line?

// It is a indicator distance From moving average
//@version=3
study("Distance From moving average")

movingType = input(title="Moving Type {SMA, EMA, WMA, HMA}", type=string, defval='SMA')
itma1 = input(title="MA", type=integer, defval=20)
price = close

hma(_src, _length)=>
_return = wma((2 * wma(_src, _length / 2)) - wma(_src, _length), round(sqrt(_length)))

ma1 = (movingType == "SMA") ? sma(close, itma1) : (movingType == "EMA") ? ema(close,itma1) : (movingType == "WMA") ? wma(close,itma1) : hma(close,itma1)

distFromMean = price - ma1

//plot(strategy.equity, title="equity", color=red, linewidth=2, style=areabr)
plot(distFromMean)

Because if use move to Hull Moving Average and TSI, zoom in zoom out will not same.
SeaSide420
//@version=3
study(title = "Hull Moving Averages and TSI", shorttitle="HMAs&TSI")
length1 = input(50, minval=1, title="Hull Length1")
length2 = input(108, minval=1, title="Hull Length2")
long = input(title="Long Length", type=integer, defval=50)
short = input(title="Short Length", type=integer, defval=50)
signal = input(title="Signal Length", type=integer, defval=26)
linebuy = input(title="Upper Line", type=integer, defval=8)
linesell = input(title="Lower Line", type=integer, defval=-8)
src = input(ohlc4, title="Source")
h2ma=2*wma(src,round(length1/2))
hma=wma(src,length1)
diff=h2ma-hma
sqn=round(sqrt(length1))
h2mab=2*wma(src[1],round(length2/2))
hmab=wma(src[1],length2)
diff1=h2mab-hmab
sqn1=round(sqrt(length2))
hma1=wma(diff,sqn)-src
hma2=wma(diff1,sqn)-src
price = src
double_smooth(src, long, short) =>
fist_smooth = ema(src, long)
ema(fist_smooth, short)
pc = change(price)
double_smoothed_pc = double_smooth(pc, long, short)
double_smoothed_abs_pc = double_smooth(abs(pc), long, short)
tsi_value = 100 * (double_smoothed_pc / double_smoothed_abs_pc)
keh = tsi_value>linesell?lime:orange
teh = ema(tsi_value, signal)>linebuy?orange:red
meh = ema(tsi_value, signal)>tsi_value?red:lime
plot(tsi_value, color=keh, linewidth=2, title='tsi_value')
plot(ema(tsi_value, signal), color=teh, linewidth=2, title='tsi_signal')
plot(linebuy,color=green, title='linebuy'),plot(linesell,color=red, title='linesell')
plot(cross(tsi_value, ema(tsi_value, signal)) ? tsi_value : na, style = circles, color=meh, linewidth = 3, title='tsi_crossover')
plot(cross(hma1/3, hma2/3) ? hma1/3 : na, style = circles, color=meh, linewidth = 3, title='hull_crossover')
hline(0, title="Zero")
c=hma1/3>hma2/3?green:red
cx=tsi_value>ema(tsi_value,signal)?white:black
d=plot(hma1/3, style = line, color=c, linewidth = 1, title='HMA1')
e=plot(hma2/3, style = line, color=c, linewidth = 1, title='HMA2')
fill(d,e,color=c, transp=75, title='cloud')
bgcolor(color = cx)
Thêm nữa