我這邊送大家一個我自己在TradingView寫指標,以前作波段時我很愛用的,我把DMI指標融入K棒的顏色(重新上色),以防止自己衝動亂接刀或追高:

1.黃綠相間>>>上漲行情 2.紫綠相間>>>震盪盤整行情 3.紫黑相間>>>下跌行情

//@version=4
study("Vegas with KDMI ", overlay=true)
f1=ema(close, 12)
f2=ema(close, 55)
f3=ema(close, 76)
f4=ema(close, 144)
f5=ema(close, 169)
f6=sma(close, 20)
plot(f1,color=color.orange, title="S")
plot(f2,color=color.blue, title="M1")
plot(f3,color=color.navy, title="M2")
plot(f4,color=color.red, title="L1")
plot(f5,color=color.purple, title="L2")
plot(f6,color=color.gray, title="SMA20")
f7=crossover(f1,f6) and close>f1
f8=crossover(f6,f1) and close<f1
plotshape(f7, style=shape.labelup,location=location.belowbar, color=color.green,title="金叉")
plotshape(f8, style=shape.labeldown,location=location.abovebar, color=color.red,title="死叉")
//KDJ
cond=barstate.islast
moveBar=input(0)
x20=input(20)+moveBar
x60=input(60)+moveBar
x120=input(120)+moveBar
plot(cond?low[20]:na,color=#FFC40C,linewidth=5,offset=-x20,style=plot.style_circles,transp=0,title="扣抵值20")
plot(cond?low[60]:na,color=#FFC40C,linewidth=5,offset=-x60,style=plot.style_circles,transp=0,title="扣抵值60")
plot(cond?low[120]:na,color=#FFC40C,linewidth=5,offset=-x120,style=plot.style_circles,transp=0,title="扣抵值120")
//KDMI語法
lensig = input(14, title="ADX Smoothing", minval=1, maxval=50)
len = input(14, minval=1, title="DI Length")
up = change(high)
down = -change(low)
plusDM = na(up) ? na : (up > down and up > 0 ? up : 0)
minusDM = na(down) ? na : (down > up and down > 0 ? down : 0)
trur = rma(tr, len)
plus = fixnan(100 * rma(plusDM, len) / trur)
minus = fixnan(100 * rma(minusDM, len) / trur)
sum = plus + minus
adx = 100 * rma(abs(plus - minus) / (sum == 0 ? 1 : sum), lensig)
strongup=change(adx)>0 and plus>minus
barcolor(strongup?color.yellow:na,title="強漲")
weakup=change(adx)<0 and plus>minus
barcolor(weakup?color.green:na,title="弱漲或漲多回檔")
strongdown=change(adx)>0 and plus<minus
barcolor(strongdown?color.black:na,title="強跌")
weakdown=change(adx)<0 and plus<minus
barcolor(weakdown?color.purple:na,title="弱跌或跌深反彈")