# TheLark: Directional Movement Index Oscillator

5318 visualizzazioni
A modified DMI, This turns the standard DMI into an Oscillator. The DMI cross signal is the same, but as an OSC you get the added benefits or finding divergences, etc. The added WIlder's Average Line (blue) can help you see if a short term trend is getting less interesting.
```study(title="TheLark: Directional Movement Index Oscillator", shorttitle="DMI-OSC_LK", overlay=false)

//•/•/•/•/•/•/•/•/•/•/•/•/•/•/•/•/•/•/•/•/•/•/•//
//                                             //
//        DMI OSCILLATOR  BY THELARK           //
//                 ~ 8-3-14 ~                  //
//                                             //
//                     •/•                     //
//                                             //
//                                             //
//•/•/•/•/•/•/•/•/•/•/•/•/•/•/•/•/•/•/•/•/•/•/•//

// Wells Wilders MA
wwma(l,p) =>
wwma = (nz(wwma[1]) * (l - 1) + p) / l

// Inputs
DMIlength = input(14)
Avglength = input(2)

// Calc
hiDiff = high - high[1]
loDiff = low[1] - low
plusDM = (hiDiff > loDiff) and (hiDiff > 0) ? hiDiff : 0
minusDM = (loDiff > hiDiff) and (loDiff > 0) ? loDiff : 0
ATR = wwma(DMIlength, tr)
PlusDI = 100 * wwma(DMIlength,plusDM) / ATR
MinusDI = 100 * wwma(DMIlength,minusDM) / ATR
osc = PlusDI - MinusDI
col = osc >= 0 ? #99EF0E : #FF0064
// Plots
plot(osc,color=col, style=histogram, linewidth=2)
plot(wwma(Avglength,osc), color=#0EAAEF,title="DI+")```