Griffiths Predictor Indicator

Forums ProRealTime English forum ProBuilder support Griffiths Predictor Indicator

Viewing 3 posts - 1 through 3 (of 3 total)
  • #241659

    Hello together,

    Result of “xBar” is always 0, so the code is not working correct.
    I expect that the error is caused by the chronological series of  “coef”  and “xBar”.
    xBar AND Coef is starting at 0, so the xbar result  is 0. After that coef will be calculated with xBar=0, the result of coef is also not correct.
    $coef[count]=0  (array pre filling, line 10 of code)
    XBar=0
    XBar= XBar + $XX[Length-count] * $Coef[count]
    $coef[count]= $coef[count] + Mu*($XX[Length]-XBar) *$XX[Length-count]

    Could you please help to correct the code.
    Many thanks in advanced

    #241670

    Hello , here is mine :

    // Griffiths Predictor Indicator by John F. Ehler
    // Adapté pour ProRealTime
    // Paramètres utilisateur
    Length =18
    BarsFwd =2
    UpperBound =40
    LowerBound =18

    // Initialisation des coefficients
    Coef1 = 0
    Coef2 = 0
    Coef3 = 0
    Coef4 = 0
    Coef5 = 0
    Coef6 = 0
    Coef7 = 0
    Coef8 = 0
    Coef9 = 0
    Coef10 = 0
    Coef11 = 0
    Coef12 = 0
    Coef13 = 0
    Coef14 = 0
    Coef15 = 0
    Coef16 = 0
    Coef17 = 0
    Coef18 = 0

    // Filtre passe-haut (High-Pass Filter)
    HPPeriod = UpperBound
    a1HP = EXP(-1.414 * 3.14159 / HPPeriod)
    b1HP = 2 * a1HP * COS(1.414 * 180 / HPPeriod)
    c2HP = b1HP
    c3HP = -(a1HP * a1HP)
    c1HP = (1 + c2HP – c3HP) / 4

    IF BARINDEX > 2 THEN
    HPPrice = (OPEN + CLOSE) / 2
    HighPass = c1HP * (HPPrice – 2 * (OPEN[1] + CLOSE[1]) / 2 + (OPEN[2] + CLOSE[2]) / 2) + c2HP * HighPass[1] + c3HP * HighPass[2]
    ELSE
    HighPass = 0
    ENDIF

    // Super Smoother Filter
    SSPeriod = LowerBound
    a1SS = EXP(-1.414 * 3.14159 / SSPeriod)
    b1SS = 2 * a1SS * COS(1.414 * 180 / SSPeriod)
    c2SS = b1SS
    c3SS = -(a1SS * a1SS)
    c1SS = 1 – c2SS – c3SS

    IF BARINDEX > 2 THEN
    SuperSmoother = c1SS * (HighPass + HighPass[1]) / 2 + c2SS * SuperSmoother[1] + c3SS * SuperSmoother[2]
    ELSE
    SuperSmoother = 0
    ENDIF

    // Signal
    LP = SuperSmoother
    IF BARINDEX > 1 THEN
    Peak = 0.991 * Peak
    ENDIF
    IF ABS(LP) > Peak THEN
    Peak = ABS(LP)
    ENDIF
    IF Peak <> 0 THEN
    Signal = LP / Peak
    ELSE
    Signal = 0
    ENDIF

    // Calcul de XBar
    Mu = 1 / Length
    XBar = Signal[0] * Coef1 + Signal[1] * Coef2 + Signal[2] * Coef3 + Signal[3] * Coef4 + Signal[4] * Coef5 +Signal[5] * Coef6 + Signal[6] * Coef7 + Signal[7] * Coef8 + Signal[8] * Coef9 + Signal[9] * Coef10 +Signal[10] * Coef11 + Signal[11] * Coef12 + Signal[12] * Coef13 + Signal[13] * Coef14 + Signal[14] * Coef15 +Signal[15] * Coef16 + Signal[16] * Coef17 + Signal[17] * Coef18

    // Mise à jour des coefficients
    Coef1 = Coef1 + Mu * (Signal – XBar) * Signal[0]
    Coef2 = Coef2 + Mu * (Signal – XBar) * Signal[1]
    Coef3 = Coef3 + Mu * (Signal – XBar) * Signal[2]
    Coef4 = Coef4 + Mu * (Signal – XBar) * Signal[3]
    Coef5 = Coef5 + Mu * (Signal – XBar) * Signal[4]
    Coef6 = Coef6 + Mu * (Signal – XBar) * Signal[5]
    Coef7 = Coef7 + Mu * (Signal – XBar) * Signal[6]
    Coef8 = Coef8 + Mu * (Signal – XBar) * Signal[7]
    Coef9 = Coef9 + Mu * (Signal – XBar) * Signal[8]
    Coef10 = Coef10 + Mu * (Signal – XBar) * Signal[9]
    Coef11 = Coef11 + Mu * (Signal – XBar) * Signal[10]
    Coef12 = Coef12 + Mu * (Signal – XBar) * Signal[11]
    Coef13 = Coef13 + Mu * (Signal – XBar) * Signal[12]
    Coef14 = Coef14 + Mu * (Signal – XBar) * Signal[13]
    Coef15 = Coef15 + Mu * (Signal – XBar) * Signal[14]
    Coef16 = Coef16 + Mu * (Signal – XBar) * Signal[15]
    Coef17 = Coef17 + Mu * (Signal – XBar) * Signal[16]
    Coef18 = Coef18 + Mu * (Signal – XBar) * Signal[17]

    // Prédiction avec BarsFwd
    XPred = 0
    FOR Advance = 1 TO BarsFwd DO
    ProjectedSignal = Signal[Advance]
    XPred = ProjectedSignal * Coef1 + Signal[Advance + 1] * Coef2 + Signal[Advance + 2] * Coef3 +Signal[Advance + 3] * Coef4 + Signal[Advance + 4] * Coef5 + Signal[Advance + 5] * Coef6 +Signal[Advance + 6] * Coef7 + Signal[Advance + 7] * Coef8 + Signal[Advance + 8] * Coef9 +Signal[Advance + 9] * Coef10 + Signal[Advance + 10] * Coef11 + Signal[Advance + 11] * Coef12 +Signal[Advance + 12] * Coef13 + Signal[Advance + 13] * Coef14 + Signal[Advance + 14] * Coef15 +Signal[Advance + 15] * Coef16 + Signal[Advance + 16] * Coef17 + Signal[Advance + 17] * Coef18
    NEXT

    // Retour des résultats
    RETURN Signal COLOURED(0, 0, 255) AS “Signal”, XPred COLOURED(255, 0, 0) AS “XPred”

    #241671

    Dear Jacques germain,

    many thanks for your code.
    It was a good idea to substitute the arrays.
    As fa as i can see so fast, your code shows nearly the results as my.
    xBar is also 0, same as my.

    In my opinion we have to figure out the problem further more.

Viewing 3 posts - 1 through 3 (of 3 total)

Create your free account now and post your request to benefit from the help of the community
Register or Login