Professional Documents
Culture Documents
Glycon
Glycon
//rsi
swr=input(true,title="RSI")
src = close, len = input(14, minval=1, title="Length RSI")
up = rma(max(change(src), 0), len)
down = rma(-min(change(src), 0), len)
rsi = down == 0 ? 100 : up == 0 ? 0 : 100 - (100 / (1 + up / down))
plot(swr?rsi:na,title="RSI", color=purple,transp=0)
//macd
swm=input(false,title="MACD")
source = close
fastLength = input(12, minval=1), slowLength=input(26,minval=1)
signalLength=input(9,minval=1)
fastMA = ema(source, fastLength)
slowMA = ema(source, slowLength)
macd = fastMA - slowMA
signal = ema(macd, signalLength)
hist = macd - signal
plot(swm?hist:na, color=red, style=histogram)
plot(swm?macd:na, color=blue)
plot(swm?signal:na, color=orange)
//stoc
sws=input(false,title="STOCHASTIC")
periodK = input(14, title="K", minval=1)
periodD = input(3, title="D", minval=1)
smoothK = input(3, title="Smooth", minval=1)
k = sma(stoch(close, high, low, periodK), smoothK)
d = sma(k, periodD)
plot(sws?k:na, title="%K", color=blue)
plot(sws?d:na, title="%D", color=orange)
h0 =plot(sws or swr?80:na)
h1 = plot(sws or swr?20:na)
fill(h0, h1, color=purple, transp=75)
//ADX
swx=input(false,title="ADX DI")
upx = change(high)
downx = -change(low)
plusDM = na(upx) ? na : (upx > downx and upx > 0 ? upx : 0)
minusDM = na(downx) ? na : (downx > upx and downx > 0 ? downx : 0)
trur = rma(tr, lenx)
plus = fixnan(100 * rma(plusDM, lenx) / trur)
minus = fixnan(100 * rma(minusDM, lenx) / trur)
sum = plus + minus
adx = 100 * rma(abs(plus - minus) / (sum == 0 ? 1 : sum), lensig)