Help with code please ADX DMI with EMA

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #23170 quote
    prttrader
    Participant
    New

    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

    #23225 quote
    Nicolas
    Keymaster
    Master

    Please 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:

    p=14
    
    plusDM = MAX(HIGH-HIGH[1], 0)
    minusDM = MAX(LOW[1]-LOW, 0)
    
    IF plusDM > minusDM THEN
    minusDM = 0
    ENDIF
    
    IF plusDM < minusDM THEN
    plusDM = 0
    ENDIF
    
    IF plusDM = minusDM THEN
    plusDM = 0
    minusDM = 0
    ENDIF
    
    plusDI = exponentialaverage[p](plusDM)//WILDERAVERAGE[p](plusDM)
    minusDI = exponentialaverage[p](minusDM)//WILDERAVERAGE[p](minusDM)
    
    DM = (plusDI-minusDI)/pointsize
    
    DX = ABS(plusDI - minusDI) / (plusDI + minusDI) * 100
    myADX = exponentialaverage[p](DX)//wilderAverage[p](DX)
    
    Return DM*10,myADX
    #23235 quote
    prttrader
    Participant
    New

    Thank you very much for your reply, what is the original code for the directional movement indicator in PRT?

     

    Thanks

    #23247 quote
    Nicolas
    Keymaster
    Master

    This one but without any of the ADX formula (lines 24 and 25) and with the Wilders average instructions I commented with //

    #23253 quote
    prttrader
    Participant
    New

    Thank 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.

    #23281 quote
    Nicolas
    Keymaster
    Master

    Oh ok, so you don’t need DMI but only DI+ and DI-, so please find below the modified code:

    p=14
    
    plusDM = MAX(HIGH-HIGH[1], 0)
    minusDM = MAX(LOW[1]-LOW, 0)
    
    IF plusDM > minusDM THEN
    minusDM = 0
    ENDIF
    
    IF plusDM < minusDM THEN
    plusDM = 0
    ENDIF
    
    IF plusDM = minusDM THEN
    plusDM = 0
    minusDM = 0
    ENDIF
    
    plusDI = exponentialaverage[p](plusDM)//WILDERAVERAGE[p](plusDM)
    minusDI = exponentialaverage[p](minusDM)//WILDERAVERAGE[p](minusDM)
    
    //DM = (plusDI-minusDI)/pointsize
    
    DX = 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-"
    #23704 quote
    prttrader
    Participant
    New

    Thank you very much for this.

Viewing 7 posts - 1 through 7 (of 7 total)
  • You must be logged in to reply to this topic.

Help with code please ADX DMI with EMA


ProBuilder: Indicators & Custom Tools

New Reply
Author
author-avatar
prttrader @prttrader Participant
Summary

This topic contains 6 replies,
has 2 voices, and was last updated by prttrader
9 years ago.

Topic Details
Forum: ProBuilder: Indicators & Custom Tools
Language: English
Started: 01/30/2017
Status: Active
Attachments: No files
Logo Logo
Loading...