MasaNakamura

ADX and DI

55356浏览
27916
55356 26
从常用的脚本中删除 添加到常用的脚本
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 回复
shreyasimijo shreyasimijo
sir i am facing a problem.can you please help me out!!
回复
p=plus,m=minus
t=p>=25 and p>m?1:m>=25 and m>p?0:t
color=t?blue:red
+1 回复
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 回复
Can you do it system tester for adx and di ?
+3 回复
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 回复
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 回复
@rvsw,

Replace:
ADX = sma(DX, len)

With:
ADX = ((nz(ADX) * (len - 1)) + DX) / len
回复
JFX_Xx JFX_Xx
ADX = ((nz(ADX) * (len - 1)) + DX) / len
+5 回复
首页 股票筛选器 外汇筛选器 加密货币筛选器 财经日历 如何运作 图表功能 价格 网站规则 版主 网站 & 经纪商解决方案 插件 图表解决方案 帮助中心 功能请求 博客 & 新闻 常见问题 维基百科 Twitter
概述 个人资料设置 账号和账单 TradingView代币 我的客服工单 帮助中心 已发表观点 粉丝 正在关注 私人消息 聊天 退出