Griffiths Predictor Indicator
Forums › ProRealTime English forum › ProBuilder support › Griffiths Predictor Indicator
- This topic has 6 replies, 2 voices, and was last updated 2 months ago by
Hasardeur.
-
-
12/21/2024 at 3:34 PM #241659Griffiths Predictor Indicator123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687REM ----------------------------------------------------REM Griffiths Predictor Indicator by John F. Ehler from Traders Tips TASC Jan 2025REM ----------------------------------------------------Length= 18BarsFwd= 2UpperBound= 40LowerBound= 18REM arraysFor count= 0 TO Length+1 Do$Coef[count]= 0NEXTREM 2-Pole roofing filterHPPrice= (open+close)/2HPPeriod= UpperBounda1= Exp(-1.414*3.14159/HPPeriod)b1= 2*a1*Cos(1.414*180/HPPeriod)c2= b1c3= -a1*a1c1= (1+ c2-c3)/4IF 4 <= barindex THEN$HighPass[barindex]= c1*(HPPrice - 2*HPPrice[1] + HPPrice[2]) + c2*$HighPass[barindex-1] + c3*$HighPass[barindex-2]ELSE$HighPass[barindex]= 0ENDIFSSPrice= $HighPass[barindex]SSPeriod= LowerBounda1= Exp(-1.414*3.14159/SSPeriod)b1= 2*a1*Cos(1.414*180/SSPeriod)c2= b1c3= -a1*a1c1= 1-c2-c3IF 4 <= barindex THEN$SuperSmoother[barindex]= c1*(SSPrice + SSPrice[1])/2 + c2*$SuperSmoother[barindex-1] + c3*$SuperSmoother[barindex-2]ELSE$SuperSmoother[barindex]= 0ENDIFLP= $SuperSmoother[barindex]REM common functionMu = 1/LengthIF 1<barindex THENPeak= 0.991 * Peak[1]ELSEPeak= 0.1ENDIFIF Peak < Abs(LP) THENPeak= Abs(LP)ENDIFIF Peak <> 0 THENSignal= LP/PeakENDIFREM Perfect cycle test signal//Signal = Sin(360*barindex / 30)FOR Count= 1 TO Length DO$XX[count]= Signal[Length-count]NEXTXBar= 0FOR Count= 1 TO Length DOXBar= XBar + $XX[Length-count] * $Coef[count]NextFOR count= 1 TO Length DO$coef[count]= $coef[count] + Mu*($XX[Length]-XBar) *$XX[Length-count]NEXTREM PredictionFOR Advance= 1 TO BarsFwd DOXPred= 0FOR count= 1 TO Length DOXPred = XPred + $XX[Length+1-count] * $coef[count]NEXTFOR count= advance TO Length-advance DO$XX[count]= $XX[count+1]NEXTFOR count= 1 TO Length-1 DO$XX[count]= $XX[count+1]NEXT$XX[Length]= XPredNEXTReturn signal coloured(0,0,250) as "Signal", XPred coloured(250,0,0) as "xPred", XBar[17] as "xBar", $coef[17] coloured(0,150,0) as "Coef"
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 advanced12/21/2024 at 7:12 PM #241670Hello , 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) / 4IF 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 – c3SSIF 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”1 user thanked author for this post.
12/21/2024 at 8:29 PM #241671Dear 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.
12/22/2024 at 10:40 AM #241679123456789101112<span class="Y2IQFc" lang="en">Initialize the coefficients to non-zero values then xbar will no longer be equal to zero</span> :<em>from</em><em>REM arrays</em><em>For count= 0 TO Length+1 Do</em><em>$Coef[count]=0</em><em>NEXT</em>toREM arraysFor count= 0 TO Length+1 Do$Coef[count]= 1/LengthNEXT112/22/2024 at 4:10 PM #241698For count= 1 to Length Do
$Coef[count]= 0
NEXTfor Count= 1 to Length DO
$XX[count]= Signal[Length-count]
NEXT
XBar= 0
for count= 1 to Length DO
$coef[count]= $coef[count] + Mu*($XX[Length]-XBar) *$XX[Length-count]
NEXT
for Count= 1 to Length DO
XBar= XBar + $XX[Length-count] * $Coef[count]
NextDear Jacques Germain,
your suggest is an elegant solution.
I tryed it by changing the position of coef and xbar calculation.
So the start figure of coef is a calculatest at xbar=o , with this coef the xBar will be calculateed.12/22/2024 at 5:22 PM #241701this one works :
Length= 18
BarsFwd= 2
UpperBound= 40
LowerBound= 18REM arrays
For count= 0 TO Length+1 Do
$Coef[count]= 1/Length
NEXTREM 2-Pole roofing filter
HPPrice= (open+close)/2
HPPeriod= UpperBound
a1= Exp(-1.414*3.14159/HPPeriod)
b1= 2*a1*Cos(1.414*180/HPPeriod)
c2= b1
c3= -a1*a1
c1= (1+ c2-c3)/4
IF 4 <= barindex THEN
$HighPass[barindex]= c1*(HPPrice – 2*HPPrice[1] + HPPrice[2]) + c2*$HighPass[barindex-1] + c3*$HighPass[barindex-2]
ELSE
$HighPass[barindex]= 0
ENDIFSSPrice= $HighPass[barindex]
SSPeriod= LowerBound
a1= Exp(-1.414*3.14159/SSPeriod)
b1= 2*a1*Cos(1.414*180/SSPeriod)
c2= b1
c3= -a1*a1
c1= 1-c2-c3
IF 4 <= barindex THEN
$SuperSmoother[barindex]= c1*(SSPrice + SSPrice[1])/2 + c2*$SuperSmoother[barindex-1] + c3*$SuperSmoother[barindex-2]
ELSE
$SuperSmoother[barindex]= 0
ENDIF
LP= $SuperSmoother[barindex]REM common function
Mu = 1/Length
IF 1<barindex THEN
Peak= 0.991 * Peak[1]
ELSE
Peak= 0.1
ENDIF
IF Peak < Abs(LP) THEN
Peak= Abs(LP)
ENDIF
IF Peak <> 0 THEN
Signal= LP/Peak
ENDIF
REM Perfect cycle test signal
//Signal = Sin(360*barindex / 30)FOR Count= 1 TO Length DO
$XX[count]= Signal[Length-count]
NEXT
XBar= 0
FOR Count= 1 TO Length DO
XBar= XBar + $XX[Length-count] * $Coef[count]
Next
FOR count= 1 TO Length DO
$coef[count]= $coef[count] + Mu*($XX[Length]-XBar) *$XX[Length-count]
NEXTREM Prediction
FOR Advance= 1 TO BarsFwd DO
XPred= 0
FOR count= 1 TO Length DO
XPred = XPred + $XX[Length+1-count] * $coef[count]
NEXT
FOR count= advance TO Length-advance DO
$XX[count]= $XX[count+1]
NEXT
FOR count= 1 TO Length-1 DO
$XX[count]= $XX[count+1]
NEXT
$XX[Length]= XPred
NEXTReturn signal coloured(0,0,250) as “Signal”, XPred coloured(250,0,0) as “xPred”, XBar[17] as “xBar”, $coef[17] coloured(0,150,0) as “Coef”
12/22/2024 at 8:33 PM #241712By comparing the both versions (GPI and GPI_Test), in my oppinion, the GPI version is more synchron to the chart.
REM initial array filling
FOR count= 1 TO Length Do
$Coef[count]= 0
NEXTFOR count= 1 TO Length DO
$coef[count]= $coef[count] + Mu*($XX[Length]-XBar) *$XX[Length-count]
NEXT
for Count= 1 to Length DO
XBar= XBar + $XX[Length-count] * $Coef[count]
Next -
AuthorPosts
Find exclusive trading pro-tools on