RimParticipant
Average
Hello,
DMI indicator is used as the RSI indicator.
Would be really great if it worked.
DMI (Directionnal Movement Index) is already a default indicator of the ProRealTime platform, are you sure this MT5 one is different?
RimParticipant
Average
Yes I am sure. This DMI is different. I have both of them. There are several adjustment options.
oh sorry, that’s the Dynamic Momentum Index, which is quite different of course. I’ll do the translation into ProBuilder’s code later today.
I’m sorry but this code have multiple dimensional arrays, which are not possible to be converted into probuilder programming language. Apparently, the RSI used into this indicator is an RSX one, I’ll try to figure out how to reconstruct the indicator without the arrays limitations.
This is what I could made, I took the RSX code I have and use the same period as the ones from the original MT5 indicator. The results are not totally the same, but quite near I suppose ..
//https://www.prorealcode.com/topic/tushar-chandes-dmi-conversion-code-mq5-to-prorealtime/
StdDevPeriod = 5 // Period of Standard Deviation
MAStdDevPeriod = 10 // Period of smoothing
MAStdDevMode = 0 // Mode of smoothing MA
DMIPeriod = 15 // Dynamic Momentum Index Period
DmiLowerLimit = 10 // Dynamic Periods Lower Bound
DmiUpperLimit = 50 // Dynamic Periods Upper Bound
LevelUp = 70 // Lower level
LevelDown = 30 // Upper level
SD = STD[StdDevPeriod](close)
ASD = Average[MAStdDevPeriod,MAStdDevMode](SD)
RSIterm = max(1,ROUND(DMIPeriod / (SD/ASD)))
RSIterm = Max(Min(RSIterm,DmiUpperLimit),DmiLowerLimit)
//RSI calculation
plus = summation[RSIterm](close-close[1]>0)
minus = summation[RSIterm](close-close[1]<0)
//plus
pow = 1
per = RSIterm
if barindex>per then
beta = 0.45*(per-1)/(0.45*(per-1)+2)
if pow=1 then
alpha = beta
elsif pow=2 then
alpha = beta*beta
elsif pow=3 then
alpha = beta*beta*beta
elsif pow=4 then
alpha = beta*beta*beta*beta
elsif pow=5 then
alpha = beta*beta*beta*beta*beta
else
alpha = beta
endif
tmp0 = (1-alpha)*plus + alpha*tmp0[1]
tmp1 = (plus - tmp0[0])*(1-beta) + beta*tmp1[1]
tmp2 = tmp0[0] + tmp1[0]
tmp3 = (tmp2[0] - tmp4[1])*((1-alpha)*(1-alpha)) + (alpha*alpha)*tmp3[1]
tmp4 = tmp4[1] + tmp3[0]
avgplus = tmp4
ftmp0 = (1-alpha)*minus + alpha*ftmp0[1]
ftmp1 = (minus - ftmp0[0])*(1-beta) + beta*ftmp1[1]
ftmp2 = ftmp0[0] + ftmp1[0]
ftmp3 = (ftmp2[0] - ftmp4[1])*((1-alpha)*(1-alpha)) + (alpha*alpha)*ftmp3[1]
ftmp4 = ftmp4[1] + ftmp3[0]
avgminus = ftmp4
endif
RS = avgplus/avgminus
DMIRSX = 100 - 100 / ( 1 + RS )
return DMIRSX as "Dynamic Momentum Index", levelup style(dottedline) as "level up", leveldown style(dottedline) as "level down"
RimParticipant
Average
Thanks for your work. Looks good. There are still missing settings.
– close
– open
– high
– low
etc. all the inputs
All the inputs are there … 9 of them. The names are the same in the code, you can compare.
I just added the “Price to use” in this version:
//https://www.prorealcode.com/topic/tushar-chandes-dmi-conversion-code-mq5-to-prorealtime/
StdDevPeriod = 5 // Period of Standard Deviation
MAStdDevPeriod = 8 // Period of smoothing
MAStdDevMode = 0 // Mode of smoothing MA
DMIPeriod = 15 // Dynamic Momentum Index Period
DmiLowerLimit = 10 // Dynamic Periods Lower Bound
DmiUpperLimit = 50 // Dynamic Periods Upper Bound
LevelUp = 70 // Lower level
LevelDown = 30 // Upper level
SD = STD[StdDevPeriod](customclose)
ASD = Average[MAStdDevPeriod,MAStdDevMode](SD)
RSIterm = max(1,ROUND(DMIPeriod / (SD/ASD)))
RSIterm = Max(Min(RSIterm,DmiUpperLimit),DmiLowerLimit)
//RSI calculation
plus = summation[RSIterm](customclose-customclose[1]>0)
minus = summation[RSIterm](customclose-customclose[1]<0)
//plus
pow = 1
per = RSIterm
if barindex>per then
beta = 0.45*(per-1)/(0.45*(per-1)+2)
if pow=1 then
alpha = beta
elsif pow=2 then
alpha = beta*beta
elsif pow=3 then
alpha = beta*beta*beta
elsif pow=4 then
alpha = beta*beta*beta*beta
elsif pow=5 then
alpha = beta*beta*beta*beta*beta
else
alpha = beta
endif
tmp0 = (1-alpha)*plus + alpha*tmp0[1]
tmp1 = (plus - tmp0[0])*(1-beta) + beta*tmp1[1]
tmp2 = tmp0[0] + tmp1[0]
tmp3 = (tmp2[0] - tmp4[1])*((1-alpha)*(1-alpha)) + (alpha*alpha)*tmp3[1]
tmp4 = tmp4[1] + tmp3[0]
avgplus = tmp4
ftmp0 = (1-alpha)*minus + alpha*ftmp0[1]
ftmp1 = (minus - ftmp0[0])*(1-beta) + beta*ftmp1[1]
ftmp2 = ftmp0[0] + ftmp1[0]
ftmp3 = (ftmp2[0] - ftmp4[1])*((1-alpha)*(1-alpha)) + (alpha*alpha)*ftmp3[1]
ftmp4 = ftmp4[1] + ftmp3[0]
avgminus = ftmp4
endif
RS = avgplus/avgminus
DMIRSX = 100 - 100 / ( 1 + RS )
return DMIRSX as "Dynamic Momentum Index", levelup style(dottedline) as "level up", leveldown style(dottedline) as "level down"
RimParticipant
Average
Thanks for your help. I have tried and can do something with it.