Indicateur AFR – Average Filter Regression
Forums › ProRealTime forum Français › Support ProBuilder › Indicateur AFR – Average Filter Regression
- This topic has 23 replies, 9 voices, and was last updated 4 years ago by robertogozzi.
Tagged: Afr, average, filter, Moving, regression
-
-
05/23/2017 at 2:50 PM #36419
Bonjour à tous, bonjour Laurenzo,
Super travail et Merci car il peut nous simplifier la vie dans nos recherches en évitant de charger 50 fois une moyenne de type différent.
Sur ma plateforme la MM type 40 (Parabolic weighted moving average) ne trace aucune ligne mais à l’inverse de la MMtype native de PRT “Moyenne de Hull”, elle ne produit aucun plantage.
Par ailleurs et au risque de passer pour un sodomiseur de diptères, dans la fenêtre “Porpriétés”, ne faudrait-il mettre en accord avec PRT l’ordre d’apparition des paramètres “periode” et “MA Type” ?
En effet, en comparant votre travail avec les quelques moyennes que PRT propose, j’ai mis un petit moment à m’apercevoir que j’inversais la période avec le type de MM. Peut-être suis-je atteint du TOC du CLIC compulsif. Probablement, d’autres confondrons aussi ces deux zones.
Surtout, ne voyez pas dans ma remarque une quelconque critique pour la critique mais plutôt un souhait d’harmonisation d’utilisation de deux produits similaires quant au contenu même si le vôtre est beaucoup plus important que celui de PRT.
Pour terminer et bien sûr vous vous en doutez, afin d’utiliser votre travail dans des indicateurs ou screeners plus personnels, le code…serait le bienvenu.
Ruddy
06/10/2017 at 2:52 PM #37982Voici le code, je vous laisse le soin de le corriger et à Nicolas de le poster s’il le souhaite dans la bibliothèque d’indicateurs.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773//---------------------------------------//// AFR - Average Filter Regression //// //// Contact: laurenzo(at)gargamail(dot)net ////---------------------------------------//// 0. Ahrens Moving Average //// 1. Adjustable Lag FIR //// 2. Arnaud Legoux Moving Average //// 3. 2-Pole Butterworth Smoothing Filter //// 4. 3-Pole Butterworth Smoothing Filter //// 5. Corrected Moving Average by A.Uhl //// 6. d9 Unscented Kalman Filter (Responsiveness Version) //// 7. d9 Unscented Kalman Filter //// 8. Double Exponential Moving Average //// 9. Exponential Least Square Moving Average //// 10. Exponential Moving Average //// 11. Elastic Volume Weighted Moving Average //// 12. Fast Adaptive Trend Line //// 13. Fractional-Bar Quick Moving Average //// 14. Fractal Adaptive Moving Average //// 15. Generalized DEMA //// 16. 1-Pole Gaussian Filter //// 17. 2-Pole Gaussian Filter //// 18. 3-Pole Gaussian Filter //// 19. 4-Pole Gaussian Filter //// 20. Hull Moving Average //// 21. IE/2 Combination of LSMA and ILRS //// 22. Integral of Linear Regression Slope //// 23. iTrend by John Ehlers //// 24. Jurik Moving Average (Responsiveness Version) //// 25. Jurik Moving Average //// 26. Kaufman Adaptive Moving Average //// 27. Kalman Filter by John Ehlers //// 28. Kalman Filter (Responsiveness Version) //// 29. Kalman Filter //// 30. Leader Exponential Moving Average //// 31. Laguerre Filter by John Ehlers //// 32. Least Square Moving Average //// 33. McGinley Dynamic //// 34. Middle High Low Range Moving Average //// 35. McNicholl Moving Average //// 36. Non Lag Moving Average (Responsiveness Version) //// 37. Non Lag Moving Average //// 38. One More Average //// 39. Pentuple Exponential Moving Average //// 40. Parabolic Weighted Moving Average //// 41. Quadruple Exponential Moving Average //// 42. Regularized EMA by Chris Satchwell //// 43. Reference Fast Trend Line //// 44. Reference Slow Trend Line //// 45. Slow Adaptive Trend Line //// 46. Simple Moving Average //// 47. 2-Pole Super Smoothing Filter //// 48. 3-Pole Super Smoothing Filter //// 49. Smoothed Simple Moving Average //// 50. Sine Weighted Moving Average //// 51. T3 Moving Average //// 52. Triple Exponential Moving Average //// 53. Triangular Moving Average //// 54. Time Series Average //// 55. Variable Index Dynamic Average //// 56. Variable Moving Average //// 57. Volume Weighted Average Price //// 58. Wilder Moving Average //// 59. Weighted Least Square Moving Average //// 60. Weighted Moving Average //// 61. Zero Lag BMT //// 62. Zero Lag Double Exponential Moving Average //// 63. Zero Lag FIR Filter //// 64. Zero Lag IIR Filter //// 65. Zero Lag John Ehlers //// 66. Zero Lag Weighted BMT //// --- parameters// MAType = 0Series = CustomClose// Period = 15// ---//------------------------------//// AHMA - Ahrens Moving Average ////------------------------------//IF MAType = 0 THENPeriod = MAX(Period, 1)IF BarIndex < Period THENAFR = SeriesELSEAFR = AFR[1] + ((Series - ((AFR[1] + AFR[Period]) / 2)) / Period)ENDIFENDIF//----------------------------//// ALFIR - Adjustable Lag FIR ////----------------------------//IF MAType = 1 THEN// Lag = 0.7 ({-2.5...2.5})Lag = 0.7AFR = (Series + (2 + Lag) * Series[1] + (3 + Lag) * Series[2] + 3 * Series[3] + (2 - Lag) * Series[4] + (1 - Lag) * Series[5] + (0 - Lag) * Series[6]) / (12 - Lag)ENDIF//-------------------------------------//// ALMA - Arnaud Legoux Moving Average ////-------------------------------------//IF MAType = 2 THENPeriod = MAX(Period, 1)// Sigma = 6 ({0..30})// Offset = 0.85 ({0..1})Sigma = 6Offset = 0.85m = ROUND(Offset * (Period - 1))s = Period / SigmaWtdSum = 0CumWt = 0FOR k = 0 TO Period - 1 DOWtd = EXP(-((k - m) * (k - m)) / (2 * s * s))WtdSum = WtdSum + Wtd * Series[Period - 1 - k]CumWt = CumWt + WtdNEXTIF CumWt <= 0 THENAFR = SeriesELSEAFR = WtdSum / CumWtENDIFENDIF//---------------------------------------------//// BSF2P - 2-Pole Butterworth Smoothing Filter ////---------------------------------------------//IF MAType = 3 THENPeriod = MAX(Period, 1)a1 = EXP(-1.414 * 3.14159 / Period)b1 = 2 * a1 * COS(1.414 * 180 / Period)coef2 = b1coef3 = -a1 * a1coef1 = (1 - b1 + a1 * a1) / 4IF BarIndex < 2 THENAFR = SeriesELSEAFR = coef1 * (Series + 2 * Series[1] + Series[2]) + coef2 * AFR[1] + coef3 * AFR[2]ENDIFENDIF//---------------------------------------------//// BSF3P - 3-Pole Butterworth Smoothing Filter ////---------------------------------------------//IF MAType = 4 THENPeriod = MAX(Period, 1)a1 = EXP(-3.14159 / Period)b1 = 2 * a1 * COS(1.738 * 180 / Period)c1 = a1 * a1coef2 = b1 + c1coef3 = -(c1 + b1 * c1)coef4 = c1 * c1coef1 = (1 - b1 + c1) * (1 - c1) / 8IF BarIndex < 3 THENAFR = SeriesELSEAFR = coef1 * (Series + 3 * Series[1] + 3 * Series[2] + Series[3]) + coef2 * AFR[1] + coef3 * AFR[2] + coef4 * AFR[3]ENDIFENDIF//-----------------------------------------//// CMA - Corrected Moving Average by A.Uhl ////-----------------------------------------//IF MAType = 5 THENPeriod = MAX(Period, 1)IF BarIndex < Period THENAFR = SeriesELSEMA = Average[Period](Series)v1 = SQUARE(STD[Period](Series))v2 = SQUARE(AFR[1] - MA)IF v2 < v1 OR v2 = 0 THENK = 0ELSEK = 1 - v1 / v2ENDIFAFR = AFR[1] + K * (MA - AFR[1])ENDIFENDIF//-------------------------------------------------------------//// d9UKF - d9 Unscented Kalman Filter (Responsiveness Version) ////-------------------------------------------------------------//IF MAType = 6 THEN// InitPeriod = MAX(Period, 2)// longAvgWindow = 65 ({40..200})longAvgWindow = 65// permissivity = {0..3}permissivity = 2windowLength = 0.5 * (Period - 1)// FIX LOG - LOG(SQRT(windowLength)) / LOG(2) + 2lengthParam = (LOG(SQRT(windowLength)) / LOG(10)) / (LOG(2) / LOG(10)) + 2IF (lengthParam < 0) THENlengthParam = 0ENDIFexpFactor = lengthParam - 2IF (expFactor < 0.5) THENexpFactor = 0.5ENDIFsigma = SQRT(windowLength) * lengthParambeta = sigma / (sigma + 1)data = Average[1](Series) // AverageVMA(Input, 1, 1)[0]; //SMA(Input, 1)[0];IF (BarIndex < 10) THENvxCum = 0hInterval = datalInterval = dataFilt0 = dataFilt1 = dataAFR = dataELSEuDelta = data - hInterval[1]uAbs = ABS(uDelta)lDelta = data - lInterval[1]lAbs = ABS(lDelta)IF (uAbs > lAbs) THENvx = uAbsELSIF (uAbs < lAbs) THENvx = lAbsELSIF (uAbs = lAbs) THENvx = 0ENDIFvxCum = vxCum[1] + 0.1 * (vx - vx[10])IF (BarIndex <= longAvgWindow + 1) THENavgVx = avgVx[1] + 2.0 * (vxCum - avgVx[1]) / (longAvgWindow + 1)ELSE// SMA(_vxCum, _longAvgWindow)avgVx = Average[longAvgWindow](vxCum) // SMA(_vxCum, _longAvgWindow)ENDIFIF (avgVx > 0) THENvxCoeff = vx / avgVxENDIF// FIX Power - Power(lengthParam, 1.0 / expFactor)IF (EXP((1.0 / expFactor) * LOG(lengthParam))) THENvxCoeff = EXP((1.0 / expFactor) * LOG(lengthParam))ENDIFIF (vxCoeff < 1) THENvxCoeff = 1ENDIF// FIX Power - Power(vxCoeff, expFactor)vExp = EXP((expFactor) * LOG(vxCoeff))// FIX Power - Power(beta, SQRT(vExp))kV = EXP(SQRT(vExp) * LOG(beta))IF (uDelta > 0) THENhInterval = dataELSEhInterval = data - kV * uDeltaENDIFIF (lDelta < 0) THENlInterval = dataELSElInterval = data - kV * lDeltaENDIFgamma = 0.45 * (Period - 1) / (0.45 * (Period - 1) + 2)// FIX Power - Power(gamma, vExp)alpha = EXP((vExp) * LOG(gamma))Filt0 = (1 - alpha) * data + alpha * Filt0[1]Det0 = (data - Filt0[0]) * (1 - gamma) + gamma * Det0[1]Filt1 = Filt0[0] + permissivity * Det0[0]Det1 = (Filt1[0] - AFR[1]) * ((1 - alpha) * (1 - alpha)) + (alpha * alpha) * Det1[1]AFR = AFR[1] + Det1[0]ENDIFENDIF//------------------------------------//// d9UKF - d9 Unscented Kalman Filter ////------------------------------------//IF MAType = 7 THEN// InitPeriod = MAX(Period, 2)// longAvgWindow = {40..200}longAvgWindow = 65// permissivity = {0..3}permissivity = 1.25windowLength = 0.5 * (Period - 1)// FIX LOG - LOG(SQRT(windowLength)) / LOG(2) + 2lengthParam = (LOG(SQRT(windowLength)) / LOG(10)) / (LOG(2) / LOG(10)) + 2IF (lengthParam < 0) THENlengthParam = 0ENDIFexpFactor = lengthParam - 2IF (expFactor < 0.5) THENexpFactor = 0.5ENDIFsigma = SQRT(windowLength) * lengthParambeta = sigma / (sigma + 1)data = Average[1](Series) // AverageVMA(Input, 1, 1)[0]; //SMA(Input, 1)[0];IF (BarIndex < 10) THENvxCum = 0hInterval = datalInterval = dataFilt0 = dataFilt1 = dataAFR = dataELSEuDelta = data - hInterval[1]uAbs = ABS(uDelta)lDelta = data - lInterval[1]lAbs = ABS(lDelta)IF (uAbs > lAbs) THENvx = uAbsELSIF (uAbs < lAbs) THENvx = lAbsELSIF (uAbs = lAbs) THENvx = 0ENDIFvxCum = vxCum[1] + 0.1 * (vx - vx[10])IF (BarIndex <= longAvgWindow + 1) THENavgVx = avgVx[1] + 2.0 * (vxCum - avgVx[1]) / (longAvgWindow + 1)ELSE// SMA(_vxCum, _longAvgWindow)avgVx = Average[longAvgWindow](vxCum) // SMA(_vxCum, _longAvgWindow)ENDIFIF (avgVx > 0) THENvxCoeff = vx / avgVxENDIF// FIX Power - Power(lengthParam, 1.0 / expFactor)IF (EXP((1.0 / expFactor) * LOG(lengthParam))) THENvxCoeff = EXP((1.0 / expFactor) * LOG(lengthParam))ENDIFIF (vxCoeff < 1) THENvxCoeff = 1ENDIF// FIX Power - Power(vxCoeff, expFactor)vExp = EXP((expFactor) * LOG(vxCoeff))// FIX Power - Power(beta, SQRT(vExp))kV = EXP(SQRT(vExp) * LOG(beta))IF (uDelta > 0) THENhInterval = dataELSEhInterval = data - kV * uDeltaENDIFIF (lDelta < 0) THENlInterval = dataELSElInterval = data - kV * lDeltaENDIFgamma = 0.45 * (Period - 1) / (0.45 * (Period - 1) + 2)// FIX Power - Power(gamma, vExp)alpha = EXP((vExp) * LOG(gamma))Filt0 = (1 - alpha) * data + alpha * Filt0[1]Det0 = (data - Filt0[0]) * (1 - gamma) + gamma * Det0[1]Filt1 = Filt0[0] + permissivity * Det0[0]Det1 = (Filt1[0] - AFR[1]) * ((1 - alpha) * (1 - alpha)) + (alpha * alpha) * Det1[1]AFR = AFR[1] + Det1[0]ENDIFENDIF//------------------------------------------//// DEMA - Double Exponential Moving Average ////------------------------------------------//IF MAType = 8 THENPeriod = MAX(Period, 1)AFR = DEMA[Period](Series)ENDIF//-------------------------------------------------//// ELSMA - Exponential Least Square Moving Average ////-------------------------------------------------//IF MAType = 9 THENPeriod = MAX(Period, 1)// NumBars = 4NumBars = 4LR = LinearRegression[NumBars](Series)AFR = ExponentialAverage[Period](LR)ENDIF//----------------------------------//// EMA - Exponential Moving Average ////----------------------------------//IF MAType = 10 THENPeriod = MAX(Period, 1)AFR = ExponentialAverage[Period](Series)ENDIF//------------------------------------------------//// EVWMA - Elastic Volume Weighted Moving Average ////------------------------------------------------//IF MAType = 11 THENPeriod = MAX(Period, 1)IF BarIndex < Period THENAFR = SeriesELSESumVol = summation[Period](Volume)IF SumVol = 0 THENSumVol = 1ENDIFAFR = ((SumVol - Volume) * AFR + Volume * Series) / SumVolENDIFENDIF//---------------------------------//// FATL - Fast Adaptive Trend Line ////---------------------------------//IF MAType = 12 THENAFR = 0.4360409450*Series[0]+0.3658689069*Series[1]+0.2460452079*Series[2]+0.1104506886*Series[3]-0.0054034585*Series[4]-0.0760367731*Series[5]-0.0933058722*Series[6]-0.0670110374*Series[7]-0.0190795053*Series[8]+0.0259609206*Series[9]+0.0502044896*Series[10]+0.0477818607*Series[11]+0.0249252327*Series[12]-0.0047706151*Series[13]-0.0272432537*Series[14]-0.0338917071*Series[15]-0.0244141482*Series[16]-0.0055774838*Series[17]+0.0128149838*Series[18]+0.0226522218*Series[19]+0.0208778257*Series[20]+0.0100299086*Series[21]-0.0036771622*Series[22]-0.0136744850*Series[23]-0.0160483392*Series[24]-0.0108597376*Series[25]-0.0016060704*Series[26]+0.0069480557*Series[27]+0.0110573605*Series[28]+0.0095711419*Series[29]+0.0040444064*Series[30]-0.0023824623*Series[31]-0.0067093714*Series[32]-0.0072003400*Series[33]-0.0047717710*Series[34]+0.0005541115*Series[35]+0.0007860160*Series[36]+0.0130129076*Series[37]+0.0040364019*Series[38]ENDIF//---------------------------------------------//// FBQMA - Fractional-Bar Quick Moving Average ////---------------------------------------------//IF MAType = 13 THENPeriod = MAX(Period, 1)Peak = Period / 3Num = 0Denom = 0FOR j = 1 TO (Period + 1) DOIF j <= Peak THENDataArray = j / PeakELSEDataArray = (Period + 1 - j) / (Period + 1 - Peak)Num = Num + Series[j - 1] * DataArrayDenom = Denom + DataArrayENDIFNEXTIF Denom <= 0 THENAFR = SeriesELSEAFR = Num / DenomENDIFENDIF//-----------------------------------------//// FRAMA - Fractal Adaptive Moving Average ////-----------------------------------------//IF MAType = 14 THENPeriod = MAX(Period, 1)N3 = (highest[Period](High) - lowest[Period](Low)) / PeriodmH = HighL = LowFOR count = 0 TO (Period / 2) - 1 DOcount = ROUND(count)IF High[count] > mH THENmH = High[count]ENDIFIF Low[count] < L THENL = Low[count]ENDIFNEXTN1 = (mH - L) / (Period / 2)HH = High[ROUND(Period / 2)]LL = Low[ROUND(Period / 2)]FOR count = Period / 2 TO Period - 1 DOcount = ROUND(count)IF High[count] > HH THENHH = High[count]ENDIFIF Low[count] < LL THENLL = Low[count]ENDIFNEXTN2 = (HH - LL) / (Period / 2)IF N1 > 0 AND N2 > 0 AND N3 > 0 THEN// FIX LOGDimen = ((LOG(N1 + N2) / LOG(10)) - (LOG(N3) / LOG(10))) / (LOG(2) / LOG(10))ENDIFalpha = EXP(-4.6 * (Dimen - 1))IF alpha < 0.01 THENalpha = 0.01ELSIF alpha > 1 THENalpha = 1ENDIFIF BarIndex < Period THENAFR = SeriesELSEAFR = alpha * Series + (1 - alpha) * AFR[1]ENDIFENDIF//--------------------------//// GDEMA - Generalized DEMA ////--------------------------//IF MAType = 15 THENPeriod = MAX(Period, 1)// VFactor = 0.7 ({-2.5..2.5})VFactor = 0.7EMA0 = ExponentialAverage[Period](Series)EMA1 = ExponentialAverage[Period](EMA0)AFR = EMA0 * (1 + VFactor) - EMA1 * VFactorENDIF//-------------------------------//// GF1P - 1-Pole Gaussian Filter ////-------------------------------//IF MAType = 16 THENPeriod = MAX(Period, 2)IF BarIndex = 0 THENw = 2 * 3.141592654 / Periodw = 180 * w / 3.141592654b = (1 - COS(w)) / (1.41421 - 1)aa = -b + SQRT(b * b + 2 * b)a1 = 1 - aay1 = SeriesENDIFy = aa * Series + a1 * y1y1 = yAFR = yENDIF//-------------------------------//// GF2P - 2-Pole Gaussian Filter ////-------------------------------//IF MAType = 17 THENPeriod = MAX(Period, 2)IF BarIndex = 0 THENw = 2 * 3.141592654 / Periodw = 180 * w / 3.141592654b = (1 - COS(w)) / (1.41421 - 1)aa = -b + SQRT(b * b + 2 * b)a1 = 1 - aaa12 = a1 * a1a2 = aa * aay1 = Seriesy2 = y1ENDIFy = a2 * Series + 2 * a1 * y1 - a12 * y2y2 = y1y1 = yAFR = yENDIF//-------------------------------//// GF3P - 3-Pole Gaussian Filter ////-------------------------------//IF MAType = 18 THENPeriod = MAX(Period, 2)IF BarIndex = 0 THENw = 2 * 3.141592654 / Periodw = 180 * w / 3.141592654b = (1 - COS(w)) / (1.25992 - 1)aa = -b + SQRT(b * b + 2 * b)a1 = 1 - aaa12 = a1 * a1a13 = a1 * a1 * a1a3 = aa * aa * aay1 = Seriesy2 = y1y3 = y2ENDIFy = a3 * Series + 3 * a1 * y1 - 3 * a12 * y2 + a13 * y3y3 = y2y2 = y1y1 = yAFR = yENDIF//-------------------------------//// GF4P - 4-Pole Gaussian Filter ////-------------------------------//IF MAType = 19 THENPeriod = MAX(Period, 2)IF BarIndex = 0 THENw = 2 * 3.141592654 / Periodw = 180 * w / 3.141592654b = (1 - COS(w)) / (1.18920 - 1)aa = -b + SQRT(b * b + 2 * b)a1 = 1 - aaa12 = a1 * a1a13 = a1 * a1 * a1a14 = a12 * a12a2 = aa * aaa4 = a2 * a2y1 = Seriesy2 = y1y3 = y2y4 = y3ENDIFy = a4 * Series + 4 * a1 * y1 - 6 * a12 * y2 + 4 * a13 *y3 - a14 * y4y4 = y3y3 = y2y2 = y1y1 = yAFR = yENDIF//---------------------------//// HMA - Hull Moving Average ////---------------------------//IF MAType = 20 THENPeriod = MAX(Period, 1)AFR = WeightedAverage[ROUND(SQRT(Period))](2 * WeightedAverage[ROUND(Period / 2)](Series) - WeightedAverage[Period](Series))ENDIF//-------------------------------------//// IE/2 - Combination of LSMA and ILRS ////-------------------------------------//IF MAType = 21 THENPeriod = MAX(Period, 2)LR = LinearRegression[Period](Series)LRS = LinearRegressionSlope[Period](Series)SMA = Average[Period](Series)AFR = (LR + LRS + SMA) / 2ENDIF//--------------------------------------------//// ILRS - Integral of Linear Regression Slope ////--------------------------------------------//IF MAType = 22 THENPeriod = MAX(Period, 2)SumBars = Period * (Period - 1) * 0.5SumSqrBars = Period * (Period - 1) * Period * (2 * Period - 1) / 6IF (BarIndex < Period) thenAFR = SeriesELSESum1 = 0SumY = 0MA = Average[1](Series)FOR i = 0 TO Period - 1 DOSum1 = Sum1 + (i * MA[i])SumY = SumY + MA[i]NEXTNum1 = Period * Sum1 - SumBars * SumYNum2 = SumBars * SumBars - Period * SumSqrBarsAFR = Num1 / Num2 + Average[Period](Series)ENDIFENDIF//--------------------------------//// iTrend - iTrend by John Ehlers ////--------------------------------//IF MAType = 23 THEN// alpha = 0.0025 {0.0025..0.2}alpha = 0.005IF BarIndex < 2 THENAFR = SeriesELSEi1 = (alpha - alpha * alpha / 4) * Seriesi2 = 0.5 * alpha * alpha * Series[1]i3 = (alpha - 0.75 * alpha * alpha) * Series[2]i4 = 2 * (1 - alpha) * AFR[1]i5 = (1 - alpha) * (1 - alpha) * AFR[2]AFR = i1 + i2 - i3 + i4 - i5ENDIFENDIF//-----------------------------------------------------//// JMA - Jurik Moving Average (Responsiveness Version) ////-----------------------------------------------------//IF MAType = 24 THENPeriod = MAX(Period, 1)// Pow = 5 ({ 1..10 })// R = 1.5 ({0.5..2.5})Pow = 5R = 1beta = 0.45 * (Period - 1) / (0.45 * (Period - 1) + 2)IF Pow = 1 THENalpha = betaELSIF Pow = 2 THENalpha = beta * betaELSIF Pow = 3 THENalpha = beta * beta * betaELSIF Pow = 4 THENalpha = beta * beta * beta * betaELSIF Pow = 5 THENalpha = beta * beta * beta * beta * betaELSIF Pow = 6 THENalpha = beta * beta * beta * beta * beta * betaELSIF Pow = 7 THENalpha = beta * beta * beta * beta * beta * beta * betaELSIF Pow = 8 THENalpha = beta * beta * beta * beta * beta * beta * beta * betaELSIF Pow = 9 THENalpha = beta * beta * beta * beta * beta * beta * beta * beta * betaELSIF Pow = 10 THENalpha = beta * beta * beta * beta * beta * beta * beta * beta * betaENDIFIF BarIndex = 0 THENFilt0 = SeriesFilt1 = SeriesAFR = SeriesELSEFilt0 = (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]ENDIFENDIF//----------------------------//// JMA - Jurik Moving Average ////----------------------------//IF MAType = 25 THENPeriod = MAX(Period, 1)// Pow = 5 ({ 1..10 })// R = 1.5 ({0.5..2.5})Pow = 4R = 1beta = 0.45 * (Period - 1) / (0.45 * (Period - 1) + 2)IF Pow = 1 THENalpha = betaELSIF Pow = 2 THENalpha = beta * betaELSIF Pow = 3 THENalpha = beta * beta * betaELSIF Pow = 4 THENalpha = beta * beta * beta * betaELSIF Pow = 5 THENalpha = beta * beta * beta * beta * betaELSIF Pow = 6 THENalpha = beta * beta * beta * beta * beta * betaELSIF Pow = 7 THENalpha = beta * beta * beta * beta * beta * beta * betaELSIF Pow = 8 THENalpha = beta * beta * beta * beta * beta * beta * beta * betaELSIF Pow = 9 THENalpha = beta * beta * beta * beta * beta * beta * beta * beta * betaELSIF Pow = 10 THENalpha = beta * beta * beta * beta * beta * beta * beta * beta * betaENDIFIF BarIndex = 0 THENFilt0 = SeriesFilt1 = SeriesAFR = SeriesELSEFilt0 = (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]ENDIFENDIF//----------------------------------------//// KAMA - Kaufman Adaptive Moving Average ////----------------------------------------//IF MAType = 26 THENPeriod = MAX(Period, 4)// FastPeriod = 7// SlowPeriod = 28FastPeriod = 7SlowPeriod = 28Fastest = 2 / (FastPeriod + 1)Slowest = 2 / (SlowPeriod + 1)IF BarIndex < Period THENAFR = SeriesELSENum = ABS(Series - Series[Period])Den = summation[Period](ABS(Series - Series[1]))ER = Num / DenAlpha = SQUARE(ER * (Fastest - Slowest) + Slowest)AFR = (Alpha * Series) + ((1 - Alpha) * AFR[1])ENDIFENDIF//-------------------------------------//// KFJE - Kalman Filter by John Ehlers ////-------------------------------------//IF MAType = 27 THENIF BarIndex < 3 THENAFR = SeriesELSEAFR = 0.33 * (Series + 0.5 * (Series - Series[3])) + 0.67 * AFR[1]ENDIFENDIF//---------------------------------------------//// KF - Kalman Filter (Responsiveness Version) ////---------------------------------------------//IF MAType = 28 THEN// K = 1000 ({1...2000})K = 1000ONCE Pred = SeriesIF BarIndex = 0 THENAFR = SeriesELSESmooth = Pred + (Series - Pred) * SQRT((K / 10000) * 2)Velo = Velo + ((K / 10000) * (Series - Pred))Pred = Smooth + VeloAFR = PredENDIFENDIF//--------------------//// KF - Kalman Filter ////--------------------//IF MAType = 29 THEN// K = 500 ({1...2000})K = 500ONCE Pred = SeriesIF BarIndex = 0 THENAFR = SeriesELSESmooth = Pred + (Series - Pred) * SQRT((K / 10000) * 2)Velo = Velo + ((K / 10000) * (Series - Pred))Pred = Smooth + VeloAFR = PredENDIFENDIF//------------------------------------------//// LEMA - Leader Exponential Moving Average ////------------------------------------------//IF MAType = 30 THENPeriod = MAX(Period, 1)IF BarIndex = 0 THENp1 = Seriesp2 = 0ELSEalpha = 2 / (Period + 1)p1 = p1[1] + alpha * (Series - p1[1])p2 = p2[1] + alpha * (Series - p1 - p2[1])ENDIFAFR = p1 + p2ENDIF//-------------------------------------//// LF - Laguerre Filter by John Ehlers ////-------------------------------------//IF MAType = 31 THEN// gamma = 0.8gamma = 0.8once l0 = Seriesonce l1 = Seriesonce l2 = Seriesonce l3 = SeriesIF BarIndex = 0 THENAFR = SeriesELSEl0 = (1 - gamma) * Series + gamma * l0[1]l1 = -gamma * l0 + l0[1] + gamma * l1[1]l2 = -gamma * l1 + l1[1] + gamma * l2[1]l3 = -gamma * l2 + l2[1] + gamma * l3[1]AFR = (l0 + 2 * l1 + 2 * l2 + l3) / 6ENDIFENDIF//------------------------------------//// LSMA - Least Square Moving Average ////------------------------------------//IF MAType = 32 THENPeriod = MAX(Period, 2)AFR = LinearRegression[Period](Series)ENDIF//-----------------------//// MD - McGinley Dynamic ////-----------------------//IF MAType = 33 THENPeriod = MAX(Period, 4)IF BarIndex = 0 THENAFR = SeriesELSEPow = (Series / AFR[1]) * (Series / AFR[1]) * (Series / AFR[1]) * (Series / AFR[1])AFR = AFR[1] + (Series - AFR[1]) / ((Period / 2) * Pow)ENDIFENDIF//----------------------------------------------//// MHLMA - Middle High Low Range Moving Average ////----------------------------------------------//IF MAType = 34 THENPeriod = MAX(Period, 1)// HLRange = 3HLRange = 3HH = highest[HLRange](High)LL = lowest[HLRange](Low)AFR = Average[Period]((HH + LL) / 2)ENDIF//---------------------------------//// MNMA - McNicholl Moving Average ////---------------------------------//IF MAType = 35 THENPeriod = MAX(Period, 2)alpha = 2 / (1 + Period)IF BarIndex = 0 THENp1 = Seriesp2 = SeriesELSEp1 = p1[1] + alpha * (Series - p1[1])p2 = p2[1] + alpha * (p1 - p2[1])ENDIFAFR = (((2 - alpha) * p1 - p2) / (1 - alpha))ENDIF//--------------------------------------------------------//// NLMA - Non Lag Moving Average (Responsiveness Version) ////--------------------------------------------------------//IF MAType = 36 THENPeriod = MAX(Period, 1)// Amplitude = 1 (0...1)// Smooth = -1 (-2...2)Amplitude = 1Smooth = 1IF Amplitude > 0 THENCoeff = 3 * 3.1415926535 / AmplitudeELSECoeff = 3 * 3.1415926535ENDIFIF Smooth < -2 THENSmooth = 0ENDIFvCycle = 4vWeight = 0vSum = 0Phase = Period + SmoothFOR i = 0 TO ((Period * vCycle) + Phase) - 1 DOIF i <= Phase - 1 THENIF Phase = 1 THENx = iELSEx = i / (Phase - 1)ENDIFELSEx = 1.0 + (i - Phase + 1) * (2.0 * vCycle - 1.0) / (vCycle * Period - 1.0)ENDIFg = Amplitude / (Coeff * x + 1.0)IF x <= 0.5 THENg = 1.0ENDIFvSum = vSum + g * COS(180 * x) * Series[i]vWeight = vWeight + g * COS(180 * x)NEXTIF vWeight > 0 THENAFR = vSum / vWeightELSEAFR = SeriesENDIFENDIF//-------------------------------//// NLMA - Non Lag Moving Average ////-------------------------------//IF MAType = 37 THENPeriod = MAX(Period, 1)// Amplitude = 0 (0...1)// Smooth = 1 (-2...2)Amplitude = 0Smooth = 1IF Amplitude > 0 THENCoeff = 3 * 3.1415926535 / AmplitudeELSECoeff = 3 * 3.1415926535ENDIFIF Smooth < -2 THENSmooth = 0ENDIFvCycle = 4vWeight = 0vSum = 0Phase = Period + SmoothFOR i = 0 TO ((Period * vCycle) + Phase) - 1 DOIF i <= Phase - 1 THENIF Phase = 1 THENx = iELSEx = i / (Phase - 1)ENDIFELSEx = 1.0 + (i - Phase + 1) * (2.0 * vCycle - 1.0) / (vCycle * Period - 1.0)ENDIFg = Amplitude / (Coeff * x + 1.0)IF x <= 0.5 THENg = 1.0ENDIFvSum = vSum + g * COS(180 * x) * Series[i]vWeight = vWeight + g * COS(180 * x)NEXTIF vWeight > 0 THENAFR = vSum / vWeightELSEAFR = SeriesENDIFENDIF//------------------------//// OMA - One More Average ////------------------------//IF MAType = 38 THEN// Sensibility = 1.5Sensibility = 1.5Period = MAX(Period, 1)Sensibility = MAX(Sensibility, -1.5)Data = Average[1](Series)averagePeriod = PeriodIF BarIndex < Period THENAFR = SeriesELSEIF averagePeriod > 1 THENminPeriod = averagePeriod / 2.0maxPeriod = minPeriod * 5.0endPeriod = ROUND(maxPeriod)signal = ABS((Data - Data[endPeriod]))noise = 0.00000000001FOR k = 1 TO endPeriod DOnoise = noise + ABS(Data - Data[k])averagePeriod = ROUND(((signal / noise) * (maxPeriod - minPeriod)) + minPeriod)NEXTENDIFalpha = (2.0 + Sensibility) / (1.0 + Sensibility + averagePeriod)e1 = e1 + alpha * (Data - e1)e2 = e2 + alpha * (e1 - e2)v1 = 1.5 * e1 - 0.5 * e2e3 = e3 + alpha * (v1 - e3)e4 = e4 + alpha * (e3 - e4)v2 = 1.5 * e3 - 0.5 * e4e5 = e5 + alpha * (v2 - e5)e6 = e6 + alpha * (e5 - e6)AFR = 1.5 * e5 - 0.5 * e6ENDIFENDIF//--------------------------------------------//// PEMA - Pentuple Exponential Moving Average ////--------------------------------------------//IF MAType = 39 THENPeriod = MAX(Period, 1)MA1 = ExponentialAverage[Period](Series)MA2 = ExponentialAverage[Period](MA1)MA3 = ExponentialAverage[Period](MA2)MA4 = ExponentialAverage[Period](MA3)MA5 = ExponentialAverage[Period](MA4)MA6 = ExponentialAverage[Period](MA5)MA7 = ExponentialAverage[Period](MA6)MA8 = ExponentialAverage[Period](MA7)AFR = (8 * MA1) - (28 * MA2) + (56 * MA3) - (70 * MA4) + (56 * MA5) - (28 * MA6) + (8 * MA7) - MA8ENDIF//------------------------------------------//// PWMA - Parabolic Weighted Moving Average ////------------------------------------------//IF MAType = 40 THENPeriod = MAX(Period, 1)Sum = SumW * SeriesSumW = Period * PeriodFOR i = 0 TO Period DOWeight = (Period - i) * (Period - i)SumW = SumW + WeightSum = Sum + Weight * Series[i]NEXTAFR = Sum / SumWENDIF//---------------------------------------------//// QEMA - Quadruple Exponential Moving Average ////---------------------------------------------//IF MAType = 41 THENPeriod = MAX(Period, 1)MA1 = ExponentialAverage[Period](Series)MA2 = ExponentialAverage[Period](MA1)MA3 = ExponentialAverage[Period](MA2)MA4 = ExponentialAverage[Period](MA3)MA5 = ExponentialAverage[Period](MA4)AFR = (5 * MA1) - (10 * MA2) + (10 * MA3) - (5 * MA4) + MA5ENDIF//-------------------------------------------//// REMA - Regularized EMA by Chris Satchwell ////-------------------------------------------//IF MAType = 42 THEN// Lambda = 0.5 ({0.5..9})Lambda = 0.5Period = MAX(Period, 1)Lambda = MAX(Lambda, 0)IF BarIndex < 2 THENAFR = SeriesELSEAFR = (AFR[1] * (1 + 2 * Lambda) + (2 / (Period + 1)) * (Series - AFR[1]) - Lambda * AFR[2]) / (1 + Lambda)ENDIFENDIF//----------------------------------//// RFTL - Reference Fast Trend Line ////----------------------------------//IF MAType = 43 THENAFR = -0.02232324*Series[0]+0.02268676*Series[1]+0.08389067*Series[2]+0.14630380*Series[3]+0.19282649*Series[4]+0.21002638*Series[5]+0.19282649*Series[6]+0.14630380*Series[7]+0.08389067*Series[8]+0.02268676*Series[9]-0.02232324*Series[10]-0.04296564*Series[11]-0.03980614*Series[12]-0.02082171*Series[13]+0.00243636*Series[14]+0.01950580*Series[15]+0.02460929*Series[16]+0.01799295*Series[17]+0.00470540*Series[18]-0.00831985*Series[19]-0.01544722*Series[20]-0.01456262*Series[21]-0.00733980*Series[22]+0.00201852*Series[23]+0.00902504*Series[24]+0.01093067*Series[25]+0.00766099*Series[26]+0.00145478*Series[27]-0.00447175*Series[28]-0.00750446*Series[29]-0.00671646*Series[30]-0.00304016*Series[31]+0.00143433*Series[32]+0.00457475*Series[33]+0.00517589*Series[34]+0.00336708*Series[35]+0.00034406*Series[36]-0.00233637*Series[37]-0.00352280*Series[38]-0.00293522*Series[39]-0.00114249*Series[40]+0.00083536*Series[41]+0.00215524*Series[42]+0.00604133*Series[43]-0.00013046*Series[44]ENDIF//----------------------------------//// RSTL - Reference Slow Trend Line ////----------------------------------//IF MAType = 44 THENAFR = -0.00514293*Series[0]-0.00398417*Series[1]-0.00262594*Series[2]-0.00107121*Series[3]+0.00066887*Series[4]+0.00258172*Series[5]+0.00465269*Series[6]+0.00686394*Series[7]+0.00919334*Series[8]+0.01161720*Series[9]+0.01411056*Series[10]+0.01664635*Series[11]+0.01919533*Series[12]+0.02172747*Series[13]+0.02421320*Series[14]+0.02662203*Series[15]+0.02892446*Series[16]+0.03109071*Series[17]+0.03309496*Series[18]+0.03490921*Series[19]+0.03651145*Series[20]+0.03788045*Series[21]+0.03899804*Series[22]+0.03984915*Series[23]+0.04042329*Series[24]+0.04071263*Series[25]+0.04071263*Series[26]+0.04042329*Series[27]+0.03984915*Series[28]+0.03899804*Series[29]+0.03788045*Series[30]+0.03651145*Series[31]+0.03490921*Series[32]+0.03309496*Series[33]+0.03109071*Series[34]+0.02892446*Series[35]+0.02662203*Series[36]+0.02421320*Series[37]+0.02172747*Series[38]+0.01919533*Series[39]+0.01664635*Series[40]+0.01411056*Series[41]+0.01161720*Series[42]+0.00919334*Series[43]+0.00686394*Series[44]+0.00465269*Series[45]+0.00258172*Series[46]+0.00066887*Series[47]-0.00107121*Series[48]-0.00262594*Series[49]-0.00398417*Series[50]-0.00514293*Series[51]-0.00609634*Series[52]-0.00684602*Series[53]-0.00739452*Series[54]-0.00774847*Series[55]-0.00791630*Series[56]-0.00790940*Series[57]-0.00774085*Series[58]-0.00742482*Series[59]-0.00697718*Series[60]-0.00641613*Series[61]-0.00576108*Series[62]-0.00502957*Series[63]-0.00423873*Series[64]-0.00340812*Series[65]-0.00255923*Series[66]-0.00170217*Series[67]-0.00085902*Series[68]-0.00004113*Series[69]+0.00073700*Series[70]+0.00146422*Series[71]+0.00213007*Series[72]+0.00272649*Series[73]+0.00324752*Series[74]+0.00368922*Series[75]+0.00405000*Series[76]+0.00433024*Series[77]+0.00453068*Series[78]+0.00465046*Series[79]+0.00469058*Series[80]+0.00466041*Series[81]+0.00457855*Series[82]+0.00442491*Series[83]+0.00423019*Series[84]+0.00399201*Series[85]+0.00372169*Series[86]+0.00342736*Series[87]+0.00311822*Series[88]+0.00280309*Series[89]+0.00249088*Series[90]+0.00219089*Series[91]+0.00191283*Series[92]+0.00166683*Series[93]+0.00146419*Series[94]+0.00131867*Series[95]+0.00124645*Series[96]+0.00126836*Series[97]-0.00401854*Series[98]ENDIF//---------------------------------//// SATL - Slow Adaptive Trend Line ////---------------------------------//IF MAType = 45 THENAFR = 0.0982862174*Series[0]+0.0975682269*Series[1]+0.0961401078*Series[2]+0.0940230544*Series[3]+0.0912437090*Series[4]+0.0878391006*Series[5]+0.0838544303*Series[6]+0.0793406350*Series[7]+0.0743569346*Series[8]+0.0689666682*Series[9]+0.0632381578*Series[10]+0.0572428925*Series[11]+0.0510534242*Series[12]+0.0447468229*Series[13]+0.0383959950*Series[14]+0.0320735368*Series[15]+0.0258537721*Series[16]+0.0198005183*Series[17]+0.0139807863*Series[18]+0.0084512448*Series[19]+0.0032639979*Series[20]-0.0015350359*Series[21]-0.0059060082*Series[22]-0.0098190256*Series[23]-0.0132507215*Series[24]-0.0161875265*Series[25]-0.0186164872*Series[26]-0.0205446727*Series[27]-0.0219739146*Series[28]-0.0229204861*Series[29]-0.0234080863*Series[30]-0.0234566315*Series[31]-0.0231017777*Series[32]-0.0223796900*Series[33]-0.0213300463*Series[34]-0.0199924534*Series[35]-0.0184126992*Series[36]-0.0166377699*Series[37]-0.0147139428*Series[38]-0.0126796776*Series[39]-0.0105938331*Series[40]-0.0084736770*Series[41]-0.0063841850*Series[42]-0.0043466731*Series[43]-0.0023956944*Series[44]-0.0005535180*Series[45]+0.0011421469*Series[46]+0.0026845693*Series[47]+0.0040471369*Series[48]+0.0052380201*Series[49]+0.0062194591*Series[50]+0.0070340085*Series[51]+0.0076266453*Series[52]+0.0080376628*Series[53]+0.0083037666*Series[54]+0.0083694798*Series[55]+0.0082901022*Series[56]+0.0080741359*Series[57]+0.0077543820*Series[58]+0.0073260526*Series[59]+0.0068163569*Series[60]+0.0062325477*Series[61]+0.0056078229*Series[62]+0.0049516078*Series[63]+0.0161380976*Series[64]ENDIF//-----------------------------//// SMA - Simple Moving Average ////-----------------------------//IF MAType = 46 THENPeriod = MAX(Period, 1)AFR = Average[Period](Series)ENDIF//---------------------------------------//// SSF2P - 2-Pole Super Smoothing Filter ////---------------------------------------//IF MAType = 47 THENPeriod = MAX(Period, 1)a1 = EXP(-1.414 * 3.14159 / Period)b1 = 2 * a1 * COS(1.414 * 180 / Period)coef2 = b1coef3 = -a1 * a1coef1 = 1 - coef2 - coef3IF BarIndex < 2 THENAFR = SeriesELSEAFR = coef1 * Series + coef2 * AFR[1] + coef3 * AFR[2]ENDIFENDIF//---------------------------------------//// SSF3P - 3-Pole Super Smoothing Filter ////---------------------------------------//IF MAType = 48 THENPeriod = MAX(Period, 1)a1 = EXP(-3.14159 / Period)b1 = 2 * a1 * COS(1.738 * 180 / Period)c1 = a1 * a1coef2 = b1 + c1coef3 = -(c1 + b1 * c1)coef4 = c1 * c1coef1 = 1 - coef2 - coef3 - coef4IF BarIndex < 3 THENAFR = SeriesELSEAFR = coef1 * Series + coef2 * AFR[1] + coef3 * AFR[2] + coef4 * AFR[3]ENDIFENDIF//---------------------------------------//// SSMA - Smoothed Simple Moving Average ////---------------------------------------//IF MAType = 49 THENPeriod = MAX(Period, 1)IF BarIndex = 0 THENAFR = SeriesELSEAFR = AFR[1] + (Series - AFR[1]) / PeriodENDIFENDIF//-------------------------------------//// SWMA - Sine Weighted Moving Average ////-------------------------------------//IF MAType = 50 THENPeriod = MAX(Period, 1)Sum = 0CSum = 0FOR j = 0 TO Period - 1 DOSum = Sum + Series[j] * SIN(90 * (1 - j / Period))CSum = CSum + SIN(90 * (1 - j / Period))NEXTIF CSum <= 0 THENAFR = SeriesELSEAFR = Sum / CSumENDIFENDIF//--------------------------//// T3MA - T3 Moving Average ////--------------------------//IF MAType = 51 THENPeriod = MAX(Period, 1)// Hot = 0.7 ({-1.5..1.5})Hot = 0.7e1 = ExponentialAverage[Period](Series)e2 = ExponentialAverage[Period](e1)e3 = ExponentialAverage[Period](e2)e4 = ExponentialAverage[Period](e3)e5 = ExponentialAverage[Period](e4)e6 = ExponentialAverage[Period](e5)b = Hotb2 = (b * b)b3 = (b * b * b)c1 = -b3c2 = (3 * b2) + (3 * b3)c3 = (-6 * b2) - (3 * b) - (3 * b3)c4 = 1 + (3 * b) + b3 + (3 * b2)AFR = c1 * e6 + c2 * e5 + c3 * e4 + c4 * e3ENDIF//------------------------------------------//// TEMA - Triple Exponential Moving Average ////------------------------------------------//IF MAType = 52 THENPeriod = MAX(Period, 1)AFR = TEMA[Period](Series)ENDIF//---------------------------------//// TMA - Triangular Moving Average ////---------------------------------//IF MAType = 53 THENPeriod = MAX(Period, 1)AFR = TriangularAverage[Period](Series)ENDIF//---------------------------//// TSA - Time Series Average ////---------------------------//IF MAType = 54 THENPeriod = MAX(Period, 1)AFR = TimeSeriesAverage[Period](Series)ENDIF//----------------------------------------//// VIDYA - Variable Index Dynamic Average ////----------------------------------------//IF MAType = 55 THENPeriod = MAX(Period, 4)// Smooth = 5Smooth = 5ONCE SC = 2 / (Smooth + 1)AbsCMO = (ABS(Chandle[Period](Series))) / 100IF BarIndex < Period THENAFR = SeriesELSEAFR = (SC * AbsCMO * Series) + (1 - (SC * AbsCMO)) * AFRENDIFENDIF//-------------------------------//// VMA - Variable Moving Average ////-------------------------------//IF MAType = 56 THENPeriod = MAX(Period, 4)IF BarIndex < Period THENAFR = SeriesELSEk = 1.0 / Periodpdm = MAX((Series - Series[1]), 0)mdm = MAX((Series[1] - Series), 0)pdmS = ((1 - k) * (pdmS[1]) + k * pdm)mdmS = ((1 - k) * (mdmS[1]) + k * mdm)s = pdmS + mdmSpdi = pdmS / smdi = mdmS / spdiS = ((1 - k) * (pdiS[1]) + k * pdi)mdiS = ((1 - k) * (mdiS[1]) + k * mdi)d = ABS(pdiS - mdiS)s1 = pdiS + mdiSiS = ((1 - k) * (iS[1]) + k * d / s1)hhv = highest[Period](iS)llv = lowest[Period](iS)d1 = hhv - llvvI = (iS - llv) / d1AFR = (1 - k * vI) * (AFR[1]) + k * vI * SeriesENDIFENDIF//--------------------------------------//// VWAP - Volume Weighted Average Price ////--------------------------------------//IF MAType = 57 THENPeriod = MAX(Period, 1)SumVol = summation[Period](Volume)IF SumVol = 0 THENSumVol = 1ENDIFAFR = summation[Period](Series * Volume) / summation[Period](Volume)ENDIF//------------------------------//// WIMA - Wilder Moving Average ////------------------------------//IF MAType = 58 THENPeriod = MAX(Period, 1)AFR = WilderAverage[Period](Series)ENDIF//----------------------------------------------//// WLSMA - Weighted Least Square Moving Average ////----------------------------------------------//IF MAType = 59 THENPeriod = MAX(Period, 1)// NumBars = 4NumBars = 4LR = LinearRegression[NumBars](Series)AFR = WeightedAverage[Period](LR)ENDIF//-------------------------------//// WMA - Weighted Moving Average ////-------------------------------//IF MAType = 60 THENPeriod = MAX(Period, 1)AFR = WeightedAverage[Period](Series)ENDIF//----------------------//// ZLBMT - Zero Lag BMT ////----------------------//IF MAType = 61 THENPeriod = MAX(Period, 1)EMA0 = ExponentialAverage[Period](Series)EMA1 = ExponentialAverage[Period](EMA0)AFR = EMA0 + (EMA0 - EMA1)ENDIF//-----------------------------------------------------//// ZLDEMA - Zero Lag Double Exponential Moving Average ////-----------------------------------------------------//IF MAType = 62 THENPeriod = MAX(Period, 1)DEMA0 = DEMA[Period](Series)DEMA1 = DEMA[Period](DEMA0)AFR = DEMA0 + (DEMA0 - DEMA1)ENDIF//----------------------------//// ZLFF - Zero Lag FIR Filter ////----------------------------//IF MAType = 63 THENAFR = (Series + 2 * Series[1] + 3 * Series[2] + 3 * Series[3] + 2 * Series[4] + Series[5]) / 12ENDIF//----------------------------//// ZLIF - Zero Lag IIR Filter ////----------------------------//IF MAType = 64 THENPeriod = MAX(Period, 1)k = 2 / (Period + 1)x = ROUND((Period - 1) / 2)IF BarIndex <= MAX(x, 0) THENAFR = SeriesELSEAFR = k * (2 * Series - Series[x]) + (1 - k) * AFR[1]ENDIFENDIF//-----------------------------//// ZLJE - Zero Lag John Ehlers ////-----------------------------//IF MAType = 65 THENPeriod = MAX(Period, 2)alpha = 2 / (1 + Period)per = ROUND((Period - 1) / 2)IF BarIndex < per THENAFR = SeriesELSEAFR = AFR[1] + alpha * (2 * Series - Series[per] - AFR[1])ENDIFENDIF//--------------------------------//// ZLWBMT - Zero Lag Weighted BMT ////--------------------------------//IF MAType = 66 THENPeriod = MAX(Period, 1)WMA0 = WeightedAverage[Period](Series)WMA1 = WeightedAverage[Period](WMA0)AFR = WMA0 + (WMA0 - WMA1)ENDIF// RETURN //RETURN AFR06/17/2017 at 1:24 PM #3850202/15/2020 at 10:47 PM #119718Merci beaucoup pour le code. Je ne pouvais pas imaginer qu'il existe de nombreuses moyennes différentes. Comment avez-vous trouvé toutes ces moyennes? Et comment avez-vous réussi à coder toutes ces différentes moyennes? Avez-vous des suggestions d'utiliser des croisements de l'une des 66 moyennes différentes pour faire une stratégie rentable? Encore merci d'avoir partagé le code! Cordialement Jan
02/15/2020 at 10:55 PM #119719Laurenzo, savez-vous peut-être quel serait le code PRT pour la convolution leavitt ? C'est peut-être déjà l'une des 66 moyennes présentées. Merci d'avance pour tout commentaire. Je l'ai demandé à https://www.prorealcode.com/topic/leavitt-convolution/
05/21/2020 at 1:56 PM #13258605/21/2020 at 2:54 PM #132609>> Merci de renseigner votre pays dans votre page de profile ! <<
🙂05/21/2020 at 6:30 PM #132677Avrain, je pense que vous devez ajouter / définir la variable "MAType", en cliquant à droite en haut du code sur "Variables", y ajouter "MAType" et définir une valeur par défaut de 1. Ensuite, dans le graphique, vous pouvez changer le MAType en 69 autres types, en sélectionnant un nombre de la moyenne souhaitée (0-69), et vous pouvez ensuite retrouver la moyenne dans le code J'espère que cela vous aidera.
05/21/2020 at 9:19 PM #132706Publiez uniquement dans la langue du forum dans laquelle vous publiez. Par exemple, l’anglais uniquement dans les forums anglophones et le français uniquement dans les forums francophones.
Merci 🙂
1 user thanked author for this post.
-
AuthorPosts
Find exclusive trading pro-tools on