trading.kay27

Kay_StochasticRSI

This is a different version of Stochastic RSI. the only difference is the use of variable moving average by Lazybear instead of regular sma for K smoothing.

Its purely an experiment. I am not a professional trader but an enthusiastic programmer trying different indicator combination to see different results.

Criticizing and negative comments will be gracefully accepted. :)
Appreciation will be even more. :)

Mã nguồn mở

Với tinh thần TradingView, tác giả của tập lệnh này đã xuất bản nó dưới dạng mã nguồn mở, vì vậy các nhà giao dịch có thể hiểu và xác minh nó. Chúc mừng tác giả! Bạn có thể sử dụng mã này miễn phí, nhưng việc sử dụng lại mã này trong một ấn phẩm chịu sự điều chỉnh của Nội quy nội bộ. Bạn có thể yêu thích nó để sử dụng nó trên biểu đồ.

Thông báo miễn trừ trách nhiệm

Thông tin và ấn phẩm không có nghĩa là và không cấu thành, tài chính, đầu tư, kinh doanh, hoặc các loại lời khuyên hoặc khuyến nghị khác được cung cấp hoặc xác nhận bởi TradingView. Đọc thêm trong Điều khoản sử dụng.

Bạn muốn sử dụng tập lệnh này trên biểu đồ?
//@version=2
//vma function is originally written by @LazyBear
//Stochastic RSI code taken from stochcharts.com
//Merging both is my brain child. (Unless someone have already thought that) :)

study(title="Kay_StochasticRSI", shorttitle="Kay_StochRSI", precision=5)
smoothK = input(3, title="Smooth K", minval=1)
smoothD = input(3, title="Smooth D", minval=1)
lengthRSI = input(14, title="RSI", minval=1)
ls = input(14, title="Stoch", minval=1)
src = input(close, title="Source")

vma(src, l) => 
    k = 2.0/(l+1)
    pdm = max((src - src[1]), 0)
    mdm = max((src[1] - src), 0)
    pdmS = ((1 - k)*nz(pdmS[1]) + k*pdm)
    mdmS = ((1 - k)*nz(mdmS[1]) + k*mdm)
    s = pdmS + mdmS
    pdi = pdmS/s
    mdi = mdmS/s
    pdiS = ((1 - k)*nz(pdiS[1]) + k*pdi)
    mdiS = ((1 - k)*nz(mdiS[1]) + k*mdi)
    d = abs(pdiS - mdiS)
    s1 = pdiS + mdiS
    iS = ((1 - k)*nz(iS[1]) + k*d/s1)
    hhv = highest(iS, l) 
    llv = lowest(iS, l) 
    d1 = hhv - llv
    vI = (iS - llv)/d1
    vma=(1 - k*vI)*nz(vma[1]) + k*vI*src
    vma

//First calculate RSI
rsi = rsi(src, lengthRSI)

//Calculate stocastic using rsi as series instead of close
st = ((rsi - lowest(rsi, ls))/(highest(rsi, ls) - lowest(rsi, ls))) * 100
//smooth out Stoch using variable moving average instead of simple moving average (no idea why I did it)
k = vma(st, smoothK)
//Smooth out K using again vma to get D
d = vma(k, smoothD)

//Color calculation.
kC=(k > k[1]) ? green : (k<k[1]) ? red : (k==k[1]) ? blue : black
plot(k, color=kC, transp=0)
plot(d, color=orange)
h0 = hline(80)
h1 = hline(20)
fill(h0, h1, color=purple, transp=80)