Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //@version=3
- study(title="VDI ADX", shorttitle="V-ADX")
- adx_len = input(13, title="ADX Smoothing")
- di_len = input(13, title="DI Length")
- threshold = input(21, title="Trend Threshold")
- overextended = input(55, title="Overextension Threshold")
- adx_smooth = input(true)
- vdi_smooth = input(true)
- smooth_offset = input(0.9, step=0.05, minval=0.1)
- smooth_sigma = input(4, step=1, minval=1)
- vwrma(_src, _len) =>
- rma(_src*volume,_len)/rma(volume,_len)
- quicksmooth(x) =>
- qtrb1 = alma(x, 2, smooth_offset, smooth_sigma)
- qtrb2 = alma(x, 3, smooth_offset, smooth_sigma)
- qtrb3 = alma(x, 5, smooth_offset, smooth_sigma)
- qtrb4 = alma(x, 8, smooth_offset, smooth_sigma)
- output = (qtrb1+qtrb2+qtrb3+qtrb4)/4
- dirmov(len) =>
- up = change(high)
- down = -change(low)
- plusDM = na(up) ? na : (up > down and up > 0 ? up : 0)
- minusDM = na(down) ? na : (down > up and down > 0 ? down : 0)
- truerange = vwrma(tr, len)
- plus = fixnan(100 * vwrma(plusDM, len) / truerange)
- minus = fixnan(100 * vwrma(minusDM, len) / truerange)
- [plus, minus]
- [di_pos, di_neg] = dirmov(di_len)
- adx(di_len, adx_len) =>
- sum = di_pos + di_neg
- output = 100 * vwrma(abs(di_pos - di_neg) / (sum == 0 ? 1 : sum), adx_len)
- di_pos_line = vdi_smooth ? quicksmooth(di_pos) : di_pos
- di_neg_line = vdi_smooth ? quicksmooth(di_neg) : di_neg
- adx_line= adx_smooth ? quicksmooth(adx(di_len, adx_len)) : adx(di_len, adx_len)
- bear = #DB7093
- bull = #98FB98
- bearcloud = #DB7093
- bullcloud = #98FB98
- forestgreen = #228B22
- crimson = #DC143C
- darkorange = #FF8C00
- xcolor = adx_line >= adx_line[1] ? darkorange : adx_line < adx_line[1] ? purple : black
- maxLevel = highest(adx_line,200)
- //Plot Definitions
- plot(adx_line, color=xcolor, style=line, linewidth=3, title="ADX")
- p1 = plot(di_pos_line, title = 'VDI Positive Flow', color=bull, transp=60, linewidth=1, editable=false)
- p2 = plot(di_neg_line, title = 'VDI Negative Flow', color=bear, transp=60, linewidth=1, editable=false)
- fill(p1, p2, color = di_pos_line > di_neg_line ? bullcloud : bearcloud, transp=80, title="VDI fill", editable=false)
- plot(maxLevel, 'Maximum', linestyle=dotted, linewidth=4, color=#808080, editable=false)
- hline(threshold,color=white, linewidth = 3, title="Trend Threshold")
- hline(overextended,color=white, linewidth = 3, title="Overextension Threshold")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement