lix

Lix_JAMES

Uses various trend algos to help indicate market turns
Open-source script

In true TradingView spirit, the author of this script has published it open-source, so traders can understand and verify it. Cheers to the author! You may use it for free, but reuse of this code in a publication is governed by House Rules. You can favorite it to use it on a chart.

Disclaimer

The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.

Want to use this script on a chart?
study(title="Lix_JAMES", shorttitle="Lix_JAMES", overlay=true)
len = input(14, minval=1, title="DI Length")
lensig = input(14, title="ADX Smoothing", minval=1, maxval=50)
up = change(high)
down = -change(low)
trur = rma(tr, len)
plus = fixnan(100 * rma(up > down and up > 0 ? up : 0, len) / trur)
minus = fixnan(100 * rma(down > up and down > 0 ? down : 0, len) / trur)
sum = plus + minus 
adx = 100 * rma(abs(plus - minus) / (sum == 0 ? 1 : sum), lensig)
//EMAs
srcEma1 = close, len1 = input(6, minval=1, title="Fast EMA")
ema1 = ema(srcEma1, len1)
srcEma2 = close, len2 = input(20, minval=1, title="Slow EMA")
ema2 = ema(srcEma2, len2)
//
//
diffEma = (100 * (ema1 - ema2) / ((ema1 + ema2) / 2))
emaSignalBuy = ema1>ema2 ? 1 : 0
//SAR
startSAR = input(0.02)
incrementSAR = input(0.02)
maximumSAR = input(0.2)
//
outSAR = sar(startSAR, incrementSAR, maximumSAR)
//MACD
sourceMCD = close
fastLengthMCD = input(12, minval=1), slowLength=input(26,minval=1)
signalLengthMCD=input(9,minval=1)
fastMACD = ema(sourceMCD, fastLengthMCD)
slowMACD = ema(sourceMCD, slowLength)
macd = fastMACD - slowMACD
signal = sma(macd, signalLengthMCD)
hist = macd - signal
//plot(hist, color=red, style=histogram)
//plot(macd, color=blue)
//plot(signal, color=orange)
isSarUp = outSAR < close ? 1 : 0
isMacdUp = signal < macd ? 1 : 0
diff = (100 * (macd - signal) / ((macd + signal) / 2))
act = abs(diff) > 0.01 and abs(diff) < 2 ? diff : 0
c = low - (low/1000000)
signalBuy = (isSarUp > 0 and isMacdUp > 0 and emaSignalBuy > 0 and adx > 20) ? (c) : na
//signalBuy = (isMacdUp > 0 and emaSignalBuy > 0) ? (c) : na
//plot(outSAR)
//plot(signalBuy)
plot(signalBuy, style=circles, color=purple, linewidth = 2)
plot(ema1, color=red)
plot(ema2)
//plot(act, color=yellow)