MasaNakamura

ADX and DI

55837 visualizzazioni
28056
55837 26
Rimuovi dagli script preferiti Aggiungi agli script preferiti
study("ADX and DI")
len = input(title="Length", type=integer, defval=14)
th = input(title="threshold", type=integer, defval=20)

TrueRange = max(max(high-low, abs(high-nz(close[1]))), abs(low-nz(close[1])))
DirectionalMovementPlus = high-nz(high[1]) > nz(low[1])-low ? max(high-nz(high[1]), 0): 0
DirectionalMovementMinus = nz(low[1])-low > high-nz(high[1]) ? max(nz(low[1])-low, 0): 0


SmoothedTrueRange = nz(SmoothedTrueRange[1]) - (nz(SmoothedTrueRange[1])/len) + TrueRange
SmoothedDirectionalMovementPlus = nz(SmoothedDirectionalMovementPlus[1]) - (nz(SmoothedDirectionalMovementPlus[1])/len) + DirectionalMovementPlus
SmoothedDirectionalMovementMinus = nz(SmoothedDirectionalMovementMinus[1]) - (nz(SmoothedDirectionalMovementMinus[1])/len) + DirectionalMovementMinus

DIPlus = SmoothedDirectionalMovementPlus / SmoothedTrueRange * 100
DIMinus = SmoothedDirectionalMovementMinus / SmoothedTrueRange * 100
DX = abs(DIPlus-DIMinus) / (DIPlus+DIMinus)*100
ADX = sma(DX, len)

plot(DIPlus, color=green, title="DI+")
plot(DIMinus, color=red, title="DI-")
plot(ADX, color=black, title="ADX")
hline(th, color=black, linestyle=dashed)
study("ADX Direction", shorttitle="Advance Decline")
input_len = input(10, title="Length")
input_sym1 = input(title="Symbol1", type=symbol, defval="NSE:HDFCBANK")
input_sym2 = input(title="Symbol2", type=symbol, defval="NSE:ICICIBANK")
input_sym3 = input(title="Symbol3", type=symbol, defval="NSE:KOTAKBANK")
input_sym4 = input(title="Symbol4", type=symbol, defval="NSE:AXISBANK")
input_sym5 = input(title="Symbol5", type=symbol, defval="NSE:SBIN")
input_sym6 = input(title="Symbol6", type=symbol, defval="NSE:INDUSINDBK")
input_sym7 = input(title="Symbol7", type=symbol, defval="NSE:FEDERALBNK")
input_sym8 = input(title="Symbol8", type=symbol, defval="NSE:YESBANK")
input_sym9 = input(title="Symbol9", type=symbol, defval="NSE:RBLBANK")
input_sym10 = input(title="Symbol10", type=symbol, defval="NSE:BANKBARODA")
no_bank = input(10,title="No of input ticks")

adxp(len) =>
upD = change(high)
downD2 = -change(low)
trurD2 = rma(tr, len)
plusD = fixnan(100 * rma(upD2 > downD2 and upD2 > 0 ? upD2 : 0, len) / trurD2)
adxn(len) =>
upD1 = change(high)
downD1 = -change(low)
trurD1 = rma(tr, len)
minusD = fixnan(100 * rma(downD1 > upD1 and downD1 > 0 ? downD : 0, len) / trurD1)
//===
P1 = (((security(input_sym1, period, adxp(input_len))) + (security(input_sym2, period, adxp(input_len))) + (security(input_sym3, period, adxp(input_len))) + (security(input_sym4, period, adxp(input_len))) + (security(input_sym5, period, adxp(input_len))) + (security(input_sym6, period, adxp(input_len))) + (security(input_sym7, period, adxp(input_len))) + (security(input_sym8, period, adxp(input_len))) + (security(input_sym9, period, adxp(input_len))) + (security(input_sym10, period, adxp(input_len))))/no_bank)
P2 = (((security(input_sym1, period, adxn(input_len))) + (security(input_sym2, period, adxn(input_len))) + (security(input_sym3, period, adxn(input_len))) + (security(input_sym4, period, adxn(input_len))) + (security(input_sym5, period, adxn(input_len))) + (security(input_sym6, period, adxn(input_len))) + (security(input_sym7, period, adxn(input_len))) + (security(input_sym8, period, adxn(input_len))) + (security(input_sym9, period, adxn(input_len))) + (security(input_sym10, period, adxn(input_len))))/no_bank)

p1 = plot(P1, color=green, linewidth = 2, transp = 0, title="DI+")
p2 = plot(P2, color=red, linewidth = 2, transp = 0, title="DI-")
+1 Rispondi
shreyasimijo shreyasimijo
sir i am facing a problem.can you please help me out!!
Rispondi
+4 Rispondi
p=plus,m=minus
t=p>=25 and p>m?1:m>=25 and m>p?0:t
color=t?blue:red
+1 Rispondi
ADX is the best ,thanks for the script with right value of input parameters and right adjustment i am sure this will generate good profit.
Thanks for helping with code ,I have been searching the code for my project BOT and AutoIndicator work.It really helped a lot to get to a concesus.


+3 Rispondi
Can you do it system tester for adx and di ?
+3 Rispondi
03.freeman Kivilcimli
@Kivilcimli, I developed a strategy based on this study. You can find it here
The scope of this startegy is to indentify best settings and inputs for winning signals.
+4 Rispondi
Thank you for the programming code. However, it seems to be incorrect. I have yet to figure out why so because the programming code . Seems to be logical. As an example, for October, 10, 2018, on a weekly chart, IWM shows ADX level of 38 while the inbuilt directional movement indicator showed 32. Overall, both the Cubs follow the same shape. However, the few points of difference is made a big difference in my back testing and that is why I ended up investigating it more
+9 Rispondi
@rvsw,

Replace:
ADX = sma(DX, len)

With:
ADX = ((nz(ADX) * (len - 1)) + DX) / len
Rispondi
JFX_Xx JFX_Xx
ADX = ((nz(ADX) * (len - 1)) + DX) / len
+5 Rispondi
Home Screener azioni Screener forex Screener cripto Calendario economico Come funziona Caratteristiche Grafico Costi Regolamento Moderatori Soluzioni per broker & siti web Widget Librerie grafiche Centro di supporto Suggerisci funzionalità Blog & Novità FAQ Wiki Twitter
Profilo Impostazioni profilo Account e fatturazione TradingView Coin I miei ticket di supporto Centro di supporto Idee pubblicate Follower Seguiti Messaggi Privati Chat Esci