Help with code please ADX DMI with EMA
Forums › ProRealTime English forum › ProBuilder support › Help with code please ADX DMI with EMA
- This topic has 6 replies, 2 voices, and was last updated 7 years ago by prttrader.
-
-
01/30/2017 at 11:04 PM #23170
Hello all, only just found this site, have been using PRT for a few years now. Would anyone know how to code ADX/Directional movement but using exponential averages instead of wilders smooth averages. I basically want the directional movement DI+ and Di – with ADX line how it is in PRT now but with exponential averages used instead of wilders. Been struggling to do this for a long time, any help would be greatly appreciated.
Thanks
01/31/2017 at 11:29 AM #23225Please find below a quick fix to get the ADX and Directional Movement Index in the same window, calculated with Exponential Moving Average instead of Wilder’s Average.
Wilders smoothing formula is almost like EMA, for your information. A bit more smoothed though.
Here is the code:
123456789101112131415161718192021222324252627p=14plusDM = MAX(HIGH-HIGH[1], 0)minusDM = MAX(LOW[1]-LOW, 0)IF plusDM > minusDM THENminusDM = 0ENDIFIF plusDM < minusDM THENplusDM = 0ENDIFIF plusDM = minusDM THENplusDM = 0minusDM = 0ENDIFplusDI = exponentialaverage[p](plusDM)//WILDERAVERAGE[p](plusDM)minusDI = exponentialaverage[p](minusDM)//WILDERAVERAGE[p](minusDM)DM = (plusDI-minusDI)/pointsizeDX = ABS(plusDI - minusDI) / (plusDI + minusDI) * 100myADX = exponentialaverage[p](DX)//wilderAverage[p](DX)Return DM*10,myADX01/31/2017 at 11:55 AM #2323501/31/2017 at 12:45 PM #2324701/31/2017 at 1:21 PM #23253Thank you for your reply. I’m new to the coding so struggling a bit. I loaded up this code and it has the adx but what i was looking for was for it to look like the one in the screenshot but calculated on the exponential with just DI+, DI- and ADX. I’m probably missing something obvious but thanks again for your reply.
01/31/2017 at 2:38 PM #23281Oh ok, so you don’t need DMI but only DI+ and DI-, so please find below the modified code:
123456789101112131415161718192021222324252627p=14plusDM = MAX(HIGH-HIGH[1], 0)minusDM = MAX(LOW[1]-LOW, 0)IF plusDM > minusDM THENminusDM = 0ENDIFIF plusDM < minusDM THENplusDM = 0ENDIFIF plusDM = minusDM THENplusDM = 0minusDM = 0ENDIFplusDI = exponentialaverage[p](plusDM)//WILDERAVERAGE[p](plusDM)minusDI = exponentialaverage[p](minusDM)//WILDERAVERAGE[p](minusDM)//DM = (plusDI-minusDI)/pointsizeDX = ABS(plusDI - minusDI) / (plusDI + minusDI)myADX = exponentialaverage[p](DX)//wilderAverage[p](DX)Return myADX as "ADX",plusDI coloured(200,0,0) as "DI+",minusDI coloured(0,200,0) as "DI-"02/02/2017 at 9:52 PM #23704 -
AuthorPosts
Find exclusive trading pro-tools on