DMI indicator DI+ and DI-
Forums › ProRealTime English forum › ProBuilder support › DMI indicator DI+ and DI-
- This topic has 7 replies, 3 voices, and was last updated 8 years ago by gregoire.
-
-
05/26/2016 at 8:27 AM #8064
Hi,
I need to create the DI+ and DI- indicators manually because I need to use them in lower TF.
I need to use DI based on daily candles on a hour time frame.
Does anyone knows how to build manually the DI+ and DI-?
(I can after this transform the indicator to work for lower TF)
Thanks
david
05/26/2016 at 9:07 AM #8079Hi David, you remember me that someone ask me the same question some days ago. Didn’t have time already to code it. Find the right formula on internet is quiet hard, but here is the metastock one, that can be easily converted:
ADX Raw
{MetaStock code written by Equis and published in the Oct99 TASC}
Periods:= Input(“Enter time periods”,1,100,14);
PlusDM:= If(HIGH>Ref(HIGH,-1) AND
LOW>=Ref(LOW,-1), HIGH-Ref(HIGH,-1),
If(HIGH>Ref(HIGH,-1) AND LOW<Ref(LOW,-1)
AND HIGH-Ref(HIGH,-1)>Ref(LOW,-1)-LOW,
HIGH-Ref(HIGH,-1), 0));
DIPlus:= 100 * Wilders(PlusDM,Periods) /
ATR(Periods);
MinusDM:= If(LOW<Ref(LOW,-1) AND
HIGH<=Ref(HIGH,-1), Ref(LOW,-1)-LOW,
If(HIGH>Ref(HIGH,-1) AND LOW<Ref(LOW,-1)
AND HIGH-Ref(HIGH,-1)<Ref(LOW,-1)-LOW,
Ref(LOW,-1)-LOW, 0));
DIMinus:= 100 * Wilders(MinusDM,Periods) /
ATR(Periods);
DIDif:= Abs(DIPlus – DIMinus);
DISum:= DIPlus + DIMinus;
ADXRaw:= 100 * Wilders(DIDif/DISum, Periods);
That’s a good exercise for your ProBuilder knowledge 🙂
05/26/2016 at 10:23 AM #8093the DI+ and DI- can be calculated in this way:
12345678910111213141516171819202122n=14plusDM = MAX(DHIGH(0)-DHIGH(1), 0)minusDM = MAX(DLOW(1)-DLOW(0), 0)IF plusDM > minusDM THENminusDM = 0ENDIFIF plusDM < minusDM THENplusDM = 0ENDIFIF plusDM = minusDM THENplusDM = 0minusDM = 0ENDIFplusDI = WILDERAVERAGE[n](plusDM)minusDI = WILDERAVERAGE[n](minusDM)Return plusDI, minusDIThe problem is how to do the wilderavarage of the PlusDM. It work in daily TF but if I reduce the TF to 1 hours the wilderavarage is done on the previus n Hours and not days…
To do so we have to create also the wilderavarage by ourself…
I am tring but with big fails for the moment…
1234567891011121314151617181920212223242526272829303132333435363738n=2K = 1/ny=2/(n+1)ONCE Ema=0ONCE plusDI=0//EMA formula = price today * y + EMA yesterday * (1-y)//Wilder EMA formula = price today * K + EMA yesterday (1-K)FOR i=0 TO n DOplusDM = MAX(DHIGH(i)-DHIGH(i+1), 0)minusDM = MAX(DLOW(i+1)-DLOW(i), 0)IF plusDM > minusDM THENminusDM = 0ENDIFIF plusDM < minusDM THENplusDM = 0ENDIFIF plusDM = minusDM THENplusDM = 0minusDM = 0ENDIFEma = PlusDM*y + Ema*(1-y)PlusDI=plusDM*k + ema//Wilder EMA formula = plusDM(0)* K + EMA yesterday (1-K)NEXT//plusDI = WILDERAVERAGE[n](plusDM)//minusDI = WILDERAVERAGE[n](minusDM)Return PlusDI05/26/2016 at 11:17 AM #8101Because you use instruction of daily OHLC! 🙂
You should replace your code with:
12plusDM = MAX(HIGH(0)-HIGH(1), 0)minusDM = MAX(LOW(1)-LOW(0), 0)So now you can use the wilderaverage instruction directly and not recode it all.
Very nice work! BIG APPLAUSE!
05/26/2016 at 11:19 AM #810205/26/2016 at 11:38 AM #8105yes Nicolas… that’s my issue 🙂
The big Applause go to another users… I copied a little from him. but… our work is 99% copy, fix and paste! 🙂
05/26/2016 at 12:10 PM #8114Ok, maybe a trick to calculate correctly the daily values is to only consider to do it only if the current bar is include in a day that is not the same as the previous bar:
123456789101112131415161718192021222324n=14plusDM = MAX(DHIGH(0)-DHIGH(1), 0)minusDM = MAX(DLOW(1)-DLOW(0), 0)if day[0]<>day[1] thenIF plusDM > minusDM THENminusDM = 0ENDIFIF plusDM < minusDM THENplusDM = 0ENDIFIF plusDM = minusDM THENplusDM = 0minusDM = 0ENDIFplusDI = WILDERAVERAGE[n](plusDM)minusDI = WILDERAVERAGE[n](minusDM)endifReturn plusDI, minusDIBut something still wrong in the returned values…
10/12/2016 at 3:58 PM #14777bonjour
j essais de modifié le di pour le faire fonctionné avec les valeur de williams R % mais je bloque en tant que débutant, monindicateur me sort bien quelque chose mais rien a voir avec le di de base.
besoin d un peu d aide merci
-
AuthorPosts
Find exclusive trading pro-tools on