yax22

DMI Yanga Indicator - @Yanga

202
DMI, modified by Yanga
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?
//
// @author yanga
//
// This DMI indicator is revised and modified by Yanga
// 
// This script is released free of charge with no warranty
// Please leave a not to the author of this script if it is used
// whole or in part
//
study("DMI Yanga Indicator - @Yanga", shorttitle="DMI_Ya")
N = input(14, title="DMI period")
M = input(6, title="Moving Average")


MTR= sum(max(max(high-low,abs(high-(close[1]))),abs(low-(close[1]))),N)
HD = high-(high[1])
LD = (low[1])-low
DMP= sum(((HD>0) and (HD>LD) ? HD : 0),N)  
DMM= sum(((LD>0) and (LD>HD) ? LD : 0),N)
PDI= DMP*100/MTR
MDI= DMM*100/MTR
ADX= sma(abs(MDI-PDI)/(MDI+PDI)*100,M)
ADXR=(ADX+(ADX[M]))/2

 
plot(PDI, color=orange)
plot(MDI, color=lime)
plot(ADX, color=fuchsia)
plot(ADXR,color=black)