TheLark

The Lark: Directional Movement Index

An open source version of the DMI. Mostly published for other scripters to modify.
Typical useage: www.investopedia.com...hnical/02/050602.asp
Skript med en öppen källkod

I sann TradingView-anda har författaren publicerat detta skript med öppen källkod så att andra handlare kan förstå och verifiera det. Hatten av för författaren! Du kan använda det gratis men återanvändning av den här koden i en publikation regleras av våra ordningsregler. Du kan ange den som favorit för att använda den i ett diagram.

Frånsägelse av ansvar

Informationen och publikationerna är inte avsedda att vara, och utgör inte heller finansiella, investerings-, handels- eller andra typer av råd eller rekommendationer som tillhandahålls eller stöds av TradingView. Läs mer i Användarvillkoren.

Vill du använda det här skriptet i ett diagram?
study(title="TheLark: Directional Movement Index", shorttitle="DMI_LK", overlay=false)

        //•/•/•/•/•/•/•/•/•/•/•/•/•/•/•/•/•/•/•/•/•/•/•//   
        //                                             //
        //        OPEN SOURCE DMI BY THELARK           //
        //                 ~ 8-3-14 ~                 //
        //                                             //
        //                     •/•                     //
        //                                             //
        //    https://www.tradingview.com/u/TheLark    //
        //                                             //
        //•/•/•/•/•/•/•/•/•/•/•/•/•/•/•/•/•/•/•/•/•/•/•//

// This is an open source version of the DMI or Directional Movement Index that is provided by Trading View.
// I made this mostly for other scripters to be able to modify and use, but it also helps with transparency,
// and proves that TV uses the correct Wells Wilder MA, and DMI. 

// More to come from me and modified DMI's :)

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

// Inputs
length = input(14)

// 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(length, tr)
PlusDI = 100 * wwma(length,plusDM) / ATR
MinusDI = 100 * wwma(length,minusDM) / ATR
DX = (PlusDI + MinusDI > 0) ? 100 * (abs(PlusDI - MinusDI) / (PlusDI + MinusDI)) : 0

// Plots
plot(wwma(length,DX),color=#FF006E,title="DX")
plot(PlusDI, color=#0EAAEF,title="DI+")
plot(MinusDI,color=orange,title="DI-")