ADX applied to OBV

If you need an Indicator or Signal developed or translated from other language, please post all Indicator development REQUESTS to this section here.

Moderator: admin

ADX applied to OBV

Postby DanPhi74 » Sat Aug 01, 2020 11:37 am

Hi Guys,

could you code this in .LUA ?
It is ADX applied to OBV and hilght when the pressure goes with Volume.
Thanks

study(title="obv-adx", shorttitle="obv-adx", format=format.price, precision=4)
len = input(22, minval=1, title="DI Length")
lensig = input(22, title="ADX Smoothing", minval=1, maxval=50)
showADX1 = input(title='ADX Line or Histogram', type=input.bool, defval=false)
showADX2 = input(title='Background Highlighting', type=input.bool, defval=false)

//================ADX=========================
up = change(obv)
down = -change(obv)
plusDM = na(up) ? na : (up > down and up > 0 ? up : 0)
minusDM = na(down) ? na : (down > up and down > 0 ? down : 0)
trur = rma(stdev(obv, len),len)
plus = fixnan(100 * ema(plusDM, len) / trur)
minus = fixnan(100 * ema(minusDM, len) / trur)
sum = plus + minus
adx = 100 * ema(abs(plus - minus) / (sum == 0 ? 1 : sum), lensig)

diDiff = plus - minus




//================Ploting True - ADX DMI=========================
plot(showADX1 ? plus:na, color=color.blue, title="+DI")
plot(showADX1 ? minus:na, color=color.orange, title="-DI")
plot(showADX1 ? adx:na, color=color.red, title="ADX")

mygreen = plus >= 22 and minus <= 18 and adx >=22
myred = minus >= 22 and adx >= 22 and plus <= 18

bgcolor(mygreen ? #00796b : na, transp=showADX2 ? 70:100, title="MyGreen")
bgcolor(myred ? #880e4f : na, transp=showADX2 ? 70:100, title="MyRed")

plotshape(crossover(plus, minus) ? showADX1 ? (plus + minus)*0.5 :na:na, location=location.absolute, style=shape.circle, color=color.green, size=size.tiny, transp=30, offset=0)
plotshape(crossover(minus, plus) ? showADX1 ? (plus + minus)*0.5 :na:na, location=location.absolute, style=shape.circle, color=color.red, size=size.tiny, transp=30, offset=0)


//================Ploting Flase - Histogram=========================
diColor = plus - minus > 0 ? (diDiff > diDiff[1] ? #45f248 : #C6FBC7) : (diDiff < diDiff[1] ? #ff7878 : #FCCFCF)
plot(showADX1 ? na : diDiff + 50, style=plot.style_columns, color=diColor, histbase=50, transp=47, title='DI Difference')

// Plots divergences
plotshape(mygreen? showADX1 ? na : diDiff + 50 : na, location=location.absolute, style=shape.triangledown, color=color.red, size=size.tiny, transp=30, offset=0)
plotshape(myred? showADX1 ? na : diDiff + 50 :na, location=location.absolute, style=shape.triangleup, color=color.green, size=size.tiny, transp=30, offset=0)


study(title="obv-adx", shorttitle="obv-adx", format=format.price, precision=4)
len = input(22, minval=1, title="DI Length")
lensig = input(22, title="ADX Smoothing", minval=1, maxval=50)
showADX1 = input(title='ADX Line or Histogram', type=input.bool, defval=false)
showADX2 = input(title='Background Highlighting', type=input.bool, defval=false)

//================ADX=========================
up = change(obv)
down = -change(obv)
plusDM = na(up) ? na : (up > down and up > 0 ? up : 0)
minusDM = na(down) ? na : (down > up and down > 0 ? down : 0)
trur = rma(stdev(obv, len),len)
plus = fixnan(100 * ema(plusDM, len) / trur)
minus = fixnan(100 * ema(minusDM, len) / trur)
sum = plus + minus
adx = 100 * ema(abs(plus - minus) / (sum == 0 ? 1 : sum), lensig)

diDiff = plus - minus




//================Ploting True - ADX DMI=========================
plot(showADX1 ? plus:na, color=color.blue, title="+DI")
plot(showADX1 ? minus:na, color=color.orange, title="-DI")
plot(showADX1 ? adx:na, color=color.red, title="ADX")

mygreen = plus >= 22 and minus <= 18 and adx >=22
myred = minus >= 22 and adx >= 22 and plus <= 18

bgcolor(mygreen ? #00796b : na, transp=showADX2 ? 70:100, title="MyGreen")
bgcolor(myred ? #880e4f : na, transp=showADX2 ? 70:100, title="MyRed")

plotshape(crossover(plus, minus) ? showADX1 ? (plus + minus)*0.5 :na:na, location=location.absolute, style=shape.circle, color=color.green, size=size.tiny, transp=30, offset=0)
plotshape(crossover(minus, plus) ? showADX1 ? (plus + minus)*0.5 :na:na, location=location.absolute, style=shape.circle, color=color.red, size=size.tiny, transp=30, offset=0)


//================Ploting Flase - Histogram=========================
diColor = plus - minus > 0 ? (diDiff > diDiff[1] ? #45f248 : #C6FBC7) : (diDiff < diDiff[1] ? #ff7878 : #FCCFCF)
plot(showADX1 ? na : diDiff + 50, style=plot.style_columns, color=diColor, histbase=50, transp=47, title='DI Difference')

// Plots divergences
plotshape(mygreen? showADX1 ? na : diDiff + 50 : na, location=location.absolute, style=shape.triangledown, color=color.red, size=size.tiny, transp=30, offset=0)
plotshape(myred? showADX1 ? na : diDiff + 50 :na, location=location.absolute, style=shape.triangleup, color=color.green, size=size.tiny, transp=30, offset=0)
DanPhi74
 
Posts: 69
Joined: Tue Dec 22, 2015 4:47 am

Re: ADX applied to OBV

Postby Apprentice » Sun Aug 02, 2020 8:25 am

Your request is added to the development list.
Development reference 1810.
User avatar
Apprentice
FXCodeBase: Confirmed User
 
Posts: 36476
Joined: Thu Dec 31, 2009 11:59 am
Location: Zagreb, Croatia



Return to Indicator and Signal Requests

Who is online

Users browsing this forum: Google [Bot] and 37 guests

cron