I have been a professional market participant for several years now and have always loved DMI/ADX, specifically DI+/DI-. @cade1332 has a lower study for just that in which it utilizes a label as shown below :
I love his script because of this label, otherwise I just use TOS DMI with an ADX label. But I really just want to use his logic to create a WL column but I cant seem to figure out how to get that numerical value of the spread (-7.71 in the screenshot above) into a watchlist column, which I figured combining it with a simple assignbackground.color would tremendously help a lot of folks, and make my life easier. I have a WL of the top 5-10 most liquid options on the day, and thought this addition would be very helpful.
You can add the TOS Default DI+ column and a DI- column, is there a way to get the sum of the two?
I dumbed the code down, commented lines out, changed plots to def - to make it as lean as I can so that I can just use the labels and not the study. As it stands, its too complex for a scan but would love to somehow figure out how to get this into a WL column.
Any takers?
Thanks in advance everyone
Like I said, a lot is commented out, so if this study interest you and you would like more than just the labels you can find his post here
I love his script because of this label, otherwise I just use TOS DMI with an ADX label. But I really just want to use his logic to create a WL column but I cant seem to figure out how to get that numerical value of the spread (-7.71 in the screenshot above) into a watchlist column, which I figured combining it with a simple assignbackground.color would tremendously help a lot of folks, and make my life easier. I have a WL of the top 5-10 most liquid options on the day, and thought this addition would be very helpful.
You can add the TOS Default DI+ column and a DI- column, is there a way to get the sum of the two?
I dumbed the code down, commented lines out, changed plots to def - to make it as lean as I can so that I can just use the labels and not the study. As it stands, its too complex for a scan but would love to somehow figure out how to get this into a WL column.
Any takers?
Thanks in advance everyone
Like I said, a lot is commented out, so if this study interest you and you would like more than just the labels you can find his post here
Code:
# ADX_DMI indicator
# cabe1332
# 20210814
# ADX code start
#declare lower;
# You can modify ADX setting below to you liking
input ADXCutoff = 25;
input DMILength = 14;
input MaFastLength = 9;
input DIRangeFilter = 10;
#DMI, ADX plots
def averageType = AverageType.WILDERS;
def hiDiff = high - high[1];
def loDiff = low[1] - low;
def plusDM = if hiDiff > loDiff and hiDiff > 0 then hiDiff else 0;
def minusDM = if loDiff > hiDiff and loDiff > 0 then loDiff else 0;
def ATR = MovingAverage(averageType, TrueRange(high, close, low), DMILength);
def "DI+" = 100 * MovingAverage(averageType, plusDM, DMILength) / ATR;
def "DI-" = 100 * MovingAverage(averageType, minusDM, DMILength) / ATR;
def DX = if ("DI+" + "DI-" > 0) then 100 * AbsValue("DI+" - "DI-") / ("DI+" + "DI-") else 0;
def ADX = MovingAverage(averageType, DX, DMILength);
#DIline - small diff = sideways
def DIrange = AbsValue(AbsValue("DI+") - AbsValue("DI-"));
#dirange.setPaintingStrategy(paintingStrategy.HISTOGRAM);
def DIok = DIrange > DIRangeFilter;
#adx filters
#plot adxavg = MovingAverage(AverageType.SIMPLE, ADX, DMILength);
def ADXOk = ADX > ADXCutoff;# and adx>adxavg;
def DMICutBull = ("DI-" < ADXCutoff and "DI+" > ADXCutoff) or ("DI+" > ADX and "DI-" < ADX) ;
def DMICutBear = ("DI+" < ADXCutoff and "DI-" > ADXCutoff) or ("DI+" < ADX and "DI-" > ADX);
def dxcrossBull = if IsNaN(dxcrossBull[1]) then "DI+" > "DI-" #for init -what it is on first bar
else if "DI+" crosses above "DI-" then 1
else if dxcrossBull[1] > 0 and "DI+" > "DI-" then 1
else 0;
#plot dxXBull=dxCrossBull;
def dxcrossBear = if IsNaN(dxcrossBear[1]) then "DI-" > "DI+"
else if "DI+" crosses below "DI-" then 1
else if dxcrossBear[1] > 0 and "DI+" < "DI-" then 1
else 0 ;
#plot dxXBear=dxCrossBear;
#==========Pivots
def pivotprice = close;
#pivots per sami. changed logic for watchlist so there is no [-1]
def engbull = close > high[1] and low <= low[1];
def engbear = close < low[1] and high >= high[1];
def pivotHigh = (low[2] > low[1] and low > low[1] and close > pivotprice[1]) or engbull ;
def pivotLow = (high[2] < high[1] and high < high[1] and close < pivotprice[1]) or engbear;
def lastPH = if IsNaN(close[1]) then low else if pivotHigh then low[1] else lastPH[1];
def lastPL = if IsNaN(close[1]) then high else if pivotLow then high[1] else lastPL[1];
def breakout = if close > lastPL and close[1] <= lastPL then 1 else 0 ;
def breakdown = if close < lastPH and close[1] >= lastPH then 1 else 0;
#=============================
def signalbull = if dxcrossBull and ADXOk and DIok then 1 else 0;
def signalbear = if dxcrossBear and ADXOk and DIok then 1 else 0;
# ignore the signal if prevsignal was same direction and had higher DI
def signal = if signalbull then 1 else if signalbear then -1 else 0;
def prevSignal = if IsNaN(prevSignal[1]) then signal[1]
else if (signal[1] <> signal) then signal[1]
else prevSignal[1];
def DAPEntry = if signalbull and !signalbull[1] and prevSignal <= 0 then 1
else if signalbear and !signalbear[1] and prevSignal >= 0 then -1
else 0;
# Entry based on mas
input ATRMult = 0.3;
def MAFast = ExpAverage(close, MaFastLength);
#vwap
def vwp = reference VWAP("time frame" = "DAY");
def ATRMod = ATRMult * ATR;
def uptrend = signalbull;
def downtrend = signalbear ;
def PivotEntry = if uptrend and pivotHigh then 1
else if downtrend and pivotLow then -1
else 0 ;
def VWPPB = if uptrend and low <= vwp + ATRMod and close > vwp then 1
else if downtrend and high >= vwp - ATRMod and close < vwp then -1
else 0 ;
#significant cross
def sigcross = if MAFast crosses above vwp and uptrend then 1.5
else if MAFast crosses below vwp and downtrend then -1.5
else 0;
#=== combined entry signal
def entry =
if sigcross <> 0 then sigcross
else
if VWPPB > 0 and PivotEntry > 0 then 2
else if VWPPB < 0 and PivotEntry < 0 then - 2
else if PivotEntry > 0 then 1
else if PivotEntry < 0 then -1
else 0
;
#======study display
def pDIPlus = "DI+";
def pDIminus = "DI-";
#pDIPlus.SetDefaultColor(Color.GREEN);
#pDIminus.SetDefaultColor(Color.RED);
#AddCloud(pDIPlus, pDIminus, Color.UPTICK);
#plot padxcutoff = ADXCutoff;
def padxcutoff = if !IsNaN(close) then ADXCutoff else Double.NaN;
#padxcutoff.assignValueColor(if (adx < adxCutoff) or (pDiminus > adxcutoff) or (pDiplus < adxCutoff) then #color.light_red else Color.green);
#padxcutoff.SetLineWeight(1);
#padxcutoff.SetPaintingStrategy(PaintingStrategy.LINE_VS_POINTS);
#adx cross plots
#pivots
def prange = 2; #pivot range
def adxbull = ADX > Lowest(ADX, prange)[1];
def adxbear = ADX < Highest(ADX, prange)[1];
#ADX.AssignValueColor(if adxbull then Color.cyan else if adxbear then Color.orange else Color.GRAY);
def ptrend = ADX;
def adxPH = if IsNaN(ptrend[-1]) then 0 else Lowest(ptrend, prange)[1] > ptrend and Lowest(ptrend, prange)[-prange] > ptrend ;
def adxPL = if IsNaN(ptrend[-1]) then 0 else Highest(ptrend, prange)[1] < ptrend and Highest(ptrend, prange)[-prange] < ptrend ;
# Trend Direction
def dmisprd = pDIPlus - pDIminus;
AddLabel(yes, if DMICutBull then "Trend Status: UP | D+: " + Round(pDIPlus, 2) + " D-: " + Round(pDIminus, 2) + " Spread: " + Round(dmisprd, 2) else "Trend Status: DOWN | D-: " + Round(pDIminus, 2) + " D+: " + Round(pDIPlus, 2) + " Spread: " + Round(dmisprd, 2), if DMICutBull then Color.GREEN else Color.RED);
# ADX Dynamic Label
# Adds ADX value and context
input ADXLength = 6;
input ADXLower = 25;
input ADXMid = 40;
input ADXHigh = 75;
#input MALength = 10;
input MALength = 9;
def ADXlabel = reference ADX(ADXLength).ADX;
def MA = reference MovAvgExponential(close, MALength);
# ADX Label
AddLabel(yes, if ADXlabel < ADXLower then " Strenght: " + Round(ADXlabel, 2) + " SETTING UP - Watch/Wait " else if ADXlabel < ADXMid then " Strenght: " + Round(ADXlabel, 2) + " CHOPPY - Watch/Wait " else if ADXlabel < ADXlabel[1] then " Strenght: " + Round(ADXlabel, 2) + " TREND WEAKENING " else if ADXlabel > ADXlabel[1] and MA > MA[1] and ADXlabel < ADXHigh then " Strenght: " + Round(ADXlabel, 2) + " UPTRENDING " else if ADXlabel > ADXlabel[1] and MA < MA[1] then " Strenght: " + Round(ADXlabel, 2) + " DOWNTRENDING " else if ADXlabel > ADXHigh then " Strenght: " + Round(ADXlabel, 2) + " HIGH/WAIT TO COOL OFF " else " ", if ADXlabel < ADXLower then Color.CYAN else if ADXlabel < ADXMid then Color.RED else if (ADXlabel < ADXlabel[1]) then Color.YELLOW else if ADXlabel > ADXlabel[1] and MA > MA[1] and ADXlabel < ADXHigh then Color.GREEN else if ADXlabel > ADXlabel[1] and MA < MA[1] then Color.RED else if ADXlabel > ADXHigh then Color.MAGENTA else Color.LIGHT_GRAY);
# end of ADX