BeikabuOyaji

ADX and DI

Remove from Favorite Scripts Add to Favorite Scripts
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)
米株親父

Comments

Hi , Nice indicator! Could you please tell me what other indicators you prefer with this for intraday trading. Thanks.
+129 Reply
Your ADX is not correct, if you want a correct ADX is necessary change:
ADX = sma(DX, len) to ---> ADX = rma(DX, len)
+70 Reply
Это самый хороший инструмент, из всех которые здесь есть. Люди хватайте его и пользуйтесь, 90% сигналов на бинарах отрабатывают в + на часовом графике, входим на 2 свечи по сигналу. Всем удачной торговли ! )))
+23 Reply
igor131 Nikolai77
@Nikolai77, Еще бы разобраться, как им пользоваться....(
+19 Reply
@igor131, xD
+2 Reply
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
+12 Reply
@rvsw,

Replace:
ADX = sma(DX, len)

With:
ADX = ((nz(ADX) * (len - 1)) + DX) / len
+8 Reply
JFX_Xx JFX_Xx
ADX = ((nz(ADX) * (len - 1)) + DX) / len
+15 Reply
Hi, it is strange but when I add this indicator to my charts it works fine but when I copy it to use in my own strategy I get an error because of the following line:
SmoothedTrueRange = nz(SmoothedTrueRange) - (nz(SmoothedTrueRange)/len) + TrueRange
because this refers to itself I get the error "Undeclared identifier `SmoothedTrueRange`;"

Any ideas?
Thanks in advance!
+11 Reply
Home Stock Screener Forex Screener Crypto Screener Economic Calendar How It Works Chart Features Pricing Refer a friend House Rules Help Center Website & Broker Solutions Widgets Charting Solutions Lightweight Charting Library Blog & News Twitter
Profile Profile Settings Account and Billing Referred friends Coins My Support Tickets Help Center Ideas Published Followers Following Private Messages Chat Sign Out