period=50
plusDM = (MAX(HIGH-HIGH[1], 0))*10
minusDM = (MAX(LOW[1]-LOW, 0))*10
IF plusDM > minusDM THEN
minusDM = 0
ENDIF
IF plusDM < minusDM THEN
plusDM = 0
ENDIF
IF plusDM = minusDM THEN
plusDM = 0
minusDM = 0
ENDIF
plusDI = WILDERAVERAGE[period](plusDM)
minusDI = WILDERAVERAGE[period](minusDM)
DM = (plusDI-minusDI)/pipsize
moy = exponentialaverage[period]((DM))
if Moy<Moy[1] and Moy[1]>Moy[2] and Moy[1]>0 then
RetB5=RetB4
RetB4=RetB3
RetB3=RetB2
RetB2=RetB1
RetB1=Moy[1]
RetBmoy=(RetB1+RetB2+RetB3+RetB4+RetB5)/5
endif
if Moy>Moy[1] and Moy[1]<Moy[2] and Moy[1]<0 then
RetH5=RetH4
RetH4=RetH3
RetH3=RetH2
RetH2=RetH1
RetH1=Moy[1]
RetHmoy=(RetH1+RetH2+RetH3+RetH4+RetH5)/5
endif
if abs(retBmoy-0) > abs(retHmoy-0) then
limitUP = retBmoy
elsif abs(retBmoy-0) < abs(retHmoy-0) then
LimitUp = -RetHmoy
endif
if abs(RetHmoy-0) > abs(RetBmoy-0) then
limitDn = RetHmoy
elsif abs(RetHmoy-0) < abs(RetBmoy-0) then
LimitDn = - RetBmoy
endif
if DM > 0 and DM > LimitUp then
drawcandle (0,0, DM, DM) COLOURED (32,0,192)
elsif DM> 0 and DM < LimitUp then
drawcandle (0,0, DM, DM) COLOURED (0,204,255)
endif
if DM < 0 and DM < LimitDn then
drawcandle (0,0, DM, DM) COLOURED (255,0,0)
elsif DM < 0 and DM > LimitDn then
drawcandle (0,0, DM, DM) COLOURED (255,204,153)
endif
Return DM as "DM", moy as "DM Moy", RetBmoy as "Moyenne 5 derniers retournements baissiers", RetHmoy as "Moyenne 5 derniers retournements haussiers"