"Tushar Chandes DMI" conversion code mq5 to prorealtime

Viewing 10 posts - 1 through 10 (of 10 total)
  • Author
    Posts
  • #57449 quote
    Rim
    Participant
    Average

    Hello,

    DMI indicator is used as the RSI indicator.

    Would be really great if it worked.

     

    #57689 quote
    Nicolas
    Keymaster
    Master
    DMI (Directionnal Movement Index) is already a default indicator of the ProRealTime platform, are you sure this MT5 one is different?
    #57809 quote
    Rim
    Participant
    Average
    Yes I am sure. This DMI is different. I have both of them. There are several adjustment options.
    #57850 quote
    Nicolas
    Keymaster
    Master
    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.
    #58610 quote
    Nicolas
    Keymaster
    Master
    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.
    #59262 quote
    Rim
    Participant
    Average
    then I wait a bit
    #59547 quote
    Nicolas
    Keymaster
    Master
    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"
    #59749 quote
    Rim
    Participant
    Average
    Thanks for your work. Looks good. There are still missing settings. – close – open – high – low etc. all the inputs
    #59766 quote
    Nicolas
    Keymaster
    Master
    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"
    #60533 quote
    Rim
    Participant
    Average
    Thanks for your help. I have tried and can do something with it.
Viewing 10 posts - 1 through 10 (of 10 total)
  • You must be logged in to reply to this topic.

"Tushar Chandes DMI" conversion code mq5 to prorealtime


ProBuilder: Indicators & Custom Tools

New Reply
Author
author-avatar
Rim @rim Participant
Summary

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

Topic Details
Forum: ProBuilder: Indicators & Custom Tools
Language: English
Started: 01/05/2018
Status: Active
Attachments: 5 files
Logo Logo
Loading...