John Ehler's – Indicator: Correlation Cycle
Forums › ProRealTime forum Italiano › Supporto ProBuilder › John Ehler's – Indicator: Correlation Cycle
- This topic has 1 reply, 2 voices, and was last updated 4 years ago by Nicolas.
-
-
05/26/2020 at 11:04 PM #133379
Buonasera a tutti,
in seguito alla pubblicazione dell’ edizione 06/2020 di Stock & Commodities dove troviamo l’articolo con il codice di John Ehlers “Correlation As A Cycle Indicator”, mi sono divertito a tradurlo in codice PRT
Lo pubblico qui, in quanto vorrei che @nicolas lo controlli prima di inserirlo in libreria per gli altri utenti.
Fonte S&C http://traders.com/Documentation/FEEDbk_docs/2020/06/TradersTips.html
Autor John F. Ehlers
John Ehlers - Correlation Cycle123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149// http://traders.com/Documentation/FEEDbk_docs/2020/06/TradersTips.html// Indicator: Correlation Cycle// Correlation Angle Indicator// (C) 2013-2020 John F. Ehlers// TASC Jun 2020// Inputs SettingPeriod = 14InputPeriod = 0 // Uses price data if 0ShowCycleIndicator = True // Booleano Indicator ModeShowCycleIndex = False // Booleano Index ModeShowPhasorAngle = False // Booleano Show Angle Phasor ModeShowMarketState = False // Booleano Show Market State Mode//Correlate over one full cycle periodLength = PeriodPrice = customClose//Creates a theoretical sinusoid having an period equal to the input period as the data inputif InputPeriod <> 0 thenPrice = Sin( 360 * Barindex / InputPeriod)endif//Correlate price with cosine wave having a fixed periodSx = 0Sy = 0Sxx = 0Sxy = 0Syy = 0for Count = 1 to Length doX = Price[count - 1]Y = Cos( 360 * ( Count - 1 ) / Period )Sx = Sx + XSy = Sy + YSxx = Sxx + X * XSxy = Sxy + X * YSyy = Syy + Y*Ynextif ( Length*Sxx - Sx*Sx > 0) and ( Length*Syy - Sy*Sy > 0 ) thenReal = ( Length*Sxy - Sx*Sy ) / SQRT( ( Length*Sxx - Sx*Sx ) * ( Length*Syy - Sy*Sy ) )endif//Correlate with a negative sine wave having a fixed periodSx = 0Sy = 0Sxx = 0Sxy = 0Syy = 0for Count = 1 to Length doX = Price[count - 1]Y = -Sin( 360 * ( count - 1 ) / Period )Sx = Sx + XSy = Sy + YSxx = Sxx + X * XSxy = Sxy + X * YSyy = Syy + Y * Ynextif ( Length*Sxx - Sx*Sx > 0 ) and ( Length*Syy - Sy*Sy > 0 ) thenImag = ( Length*Sxy - Sx*Sy ) / SqRt( ( Length*Sxx - Sx*Sx ) *( Length*Syy - Sy*Sy ) )endif//Compute the angle as an arctangent function and resolve ambiguityif Imag <> 0 thenAngle = 90 + Atan( Real / Imag )Endifif Imag > 0 thenAngle = Angle - 180Endif//Do not allow the rate change of angle to go negativeif Angle[1] - Angle < 270 and Angle < Angle[1] thenAngle = Angle[1]Endif//Compute and plot market stateState = 0if Abs( Angle - Angle[1] ) < 9 and Angle <= 0 thenState = -1Endifif Abs( Angle - Angle[1] ) < 9 and Angle >= 0 thenState = 1EndifIf ShowCycleIndicator ThenRealshow = (((real+1)/2)*200)-100Imagshow = (((Imag+1)/2)*200)-100r=169g=169b=169if Realshow>Imagshow thenr=34g=139b=34elsif Realshow<Imagshow thenr=220g=20b=60endifZeroLine = 0EndifIf ShowCycleIndex ThenRealshow = (((real+1)/2)*100)Imagshow = (((Imag+1)/2)*100)r=169g=169b=169if Realshow>Imagshow thenr=34g=139b=34elsif Realshow<Imagshow thenr=220g=20b=60endifZeroLine = 50EndifIf ShowPhasorAngle ThenAngleShow = Angleif AngleShow>0 thenr=34g=139b=34elsif AngleShow<0 thenr=220g=20b=60endifZeroLine = 0EndifIf ShowMarketState ThenStateShow = State*100if StateShow>0 thenr=34g=139b=34elsif StateShow<0 thenr=220g=20b=60EndifZeroLine = 0EndifReturn Realshow coloured(r,g,b) as "Real", Imagshow coloured(153,153,153) as "Imag" ,AngleShow coloured(r,g,b) as "Phasor", StateShow coloured(r,g,b) Style(Histogram,1) as "Correlation Cycle Ind", ZeroLine coloured(153,153,153) as "Zero Line"Saluti Actaru5
05/27/2020 at 8:36 AM #133397Molte grazie! Molto gentile da parte tua per condividere il codice che hai tradotto! L'ho provato e non ho visto alcun errore. Potrei chiederti più aiuto? Pubblicandolo con il tuo nome nella libreria usando questa pagina: condividi il tuo codice nella libreria 😉
-
AuthorPosts
Find exclusive trading pro-tools on