Conversion of Jurik Filter from mq4

Viewing 12 posts - 1 through 12 (of 12 total)
  • Author
    Posts
  • #88002 quote
    rigel
    Participant
    Average

    Hi Nicolas,

    Found this forum that is dedicated to Jurik tools https://www.forexfactory.com/showthread.php?t=696822 , it would be great if you could add to our arsenal those tools. For a start here the Jurik Filter

    [img]https://www.forexfactory.com/attachment.php?attachmentid=2466564&stc=1&thumb=1&d=1504476438[/img]

    rgds

    #88051 quote
    rigel
    Participant
    Average

    Noticed that there is a newer version that solved some bug

    #88081 quote
    Nicolas
    Keymaster
    Master

    These 2 versions of the Jurik moving average could help:

    //----------------------------//
    // JMA - Jurik Moving Average //
    //----------------------------//
    
    Period = 20
    
    Period = MAX(Period, 1)
    
    // Pow = 5 ({ 1..10 })
    // R = 1.5 ({0.5..2.5})
    Pow = 4
    R = 1
    
    beta = 0.45 * (Period - 1) / (0.45 * (Period - 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
    ELSIF Pow = 6 THEN
    alpha = beta * beta * beta * beta * beta * beta
    ELSIF Pow = 7 THEN
    alpha = beta * beta * beta * beta * beta * beta * beta
    ELSIF Pow = 8 THEN
    alpha = beta * beta * beta * beta * beta * beta * beta * beta
    ELSIF Pow = 9 THEN
    alpha = beta * beta * beta * beta * beta * beta * beta * beta * beta
    ELSIF Pow = 10 THEN
    alpha = beta * beta * beta * beta * beta * beta * beta * beta * beta
    ENDIF
    
    IF BarIndex = 0 THEN
    Filt0 = Series
    Filt1 = Series
    AFR = Series
    ELSE
    Filt0 = (1 - alpha) * Series + alpha * Filt0[1]
    Det0 = (Series - Filt0[0]) * (1 - beta) + beta * Det0[1]
    Filt1 = Filt0[0] + R * Det0[0]
    Det1 = (Filt1[0] - AFR[1]) * ((1 - alpha) * (1 - alpha)) + (alpha * alpha) * Det1[1]
    AFR = AFR[1] + Det1[0]
    ENDIF
    
    RETURN AFR
    //-----------------------------------------------------//
    // JMA - Jurik Moving Average (Responsiveness Version) //
    //-----------------------------------------------------//
    
    Period = 20
    
    Period = MAX(Period, 1)
    
    // Pow = 5 ({ 1..10 })
    // R = 1.5 ({0.5..2.5})
    Pow = 5
    R = 1
    
    beta = 0.45 * (Period - 1) / (0.45 * (Period - 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
    ELSIF Pow = 6 THEN
    alpha = beta * beta * beta * beta * beta * beta
    ELSIF Pow = 7 THEN
    alpha = beta * beta * beta * beta * beta * beta * beta
    ELSIF Pow = 8 THEN
    alpha = beta * beta * beta * beta * beta * beta * beta * beta
    ELSIF Pow = 9 THEN
    alpha = beta * beta * beta * beta * beta * beta * beta * beta * beta
    ELSIF Pow = 10 THEN
    alpha = beta * beta * beta * beta * beta * beta * beta * beta * beta
    ENDIF
    
    IF BarIndex = 0 THEN
    Filt0 = Series
    Filt1 = Series
    AFR = Series
    ELSE
    Filt0 = (1 - alpha) * Series + alpha * Filt0[1]
    Det0 = (Series - Filt0[0]) * (1 - beta) + beta * Det0[1]
    Filt1 = Filt0[0] + R * Det0[0]
    Det1 = (Filt1[0] - AFR[1]) * ((1 - alpha) * (1 - alpha)) + (alpha * alpha) * Det1[1]
    AFR = AFR[1] + Det1[0]
    ENDIF
    
    RETURN AFR

    You can adjust the “Period”, “Pow” and “R” values directly into the code.

    #88085 quote
    Vonasi
    Moderator
    Master

    Should line 35 not have one more * Beta?

    Perhaps also using a loop would be better way to calculate alpha?

    #88092 quote
    Nicolas
    Keymaster
    Master

    Should line 35 not have one more * Beta?

    I think you are right, codes taken from this indi: Average Filter Regression

    Perhaps also using a loop would be better way to calculate alpha?

    A more classy way for sure, but not sure about performance.

    #88096 quote
    Vonasi
    Moderator
    Master

    A more classy way for sure, but not sure about performance.

    Yes loops are a much neater solution but they can make things a bit slow and I guess if the Pow only needs to be set to something between 1 and 10 then repetitive typing is the way to go.

    Maybe when I have more time I will do a comparison speed test!

    #88345 quote
    rigel
    Participant
    Average

    Thanks Vonasi, Nicolas

    However I think that the .mq4 filter is not simply the Jurik moving average that you posted, the plot does not have the strai9ght flat sections showed in the chart.

    Am I missing something?

     

    rgds

    #88374 quote
    Nicolas
    Keymaster
    Master

    The flat section you see is because this indicator is multiple timeframe and plot the superior timeframes values of that moving average.

    ProBuilder is not MTF compatible, but the code I gave you above is similar to the MT4 version on the same timeframe.

    #88379 quote
    rigel
    Participant
    Average

    Thanks Nicolas, clear.

    #117496 quote
    Wolf
    Participant
    Average

    Hi, Thank you Nicolas for this code.

    If you want use a calculation of power inside PRT code it is very simply and not necessary to use condition “If” heavy and longer.
    So you can remplace ligne 16 to 36 by just one line: So no limit of power and code very light.

    falpha = exp ( Pow * log(fbeta) )

    Explanation:

    A (power x) = exponential (x *natural logarithm (A))   [natural logarithm = “logarithme népérien” in French)

    It is only mathematical property, I have nothing invented. (LOL)

    #117497 quote
    Nicolas
    Keymaster
    Master

    Thank you @Wolf. We are used to use this Math Pow version also in some other codes! 🙂

    A new instruction for POW is in the pipe and should be added very soon in version 11.

    #151111 quote
    Patrick K Templar
    Participant
    Average

    I get a syntax error the following variable is undefined series

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

Conversion of Jurik Filter from mq4


ProBuilder: Indicators & Custom Tools

New Reply
Author
author-avatar
rigel @rigel Participant
Summary

This topic contains 11 replies,
has 5 voices, and was last updated by Patrick K Templar
5 years, 2 months ago.

Topic Details
Forum: ProBuilder: Indicators & Custom Tools
Language: English
Started: 01/04/2019
Status: Active
Attachments: 2 files
Logo Logo
Loading...