// IndCyclePeriodogram // AutoCorrelation Periodogram // John F. Ehlers // TASC September 2016 // v0.1 // Parameters // Once AvgLength = 3 // Averaging Bars for Pearson Correlation // Once CycleMin = 8 // Cycle Minimum Bars between 4 and 10 // Once CycleMax = 48 // Cycle Maximum Bars between 10 and 60 // Once EnhanceResolution = 0 // Enhance Normalization Display Resolution // Indicators // -> Autocorrelation Periodogram Once MinBarsRequired = AvgLength + CycleMax Once AutoPeriodDelta = 0 Once AutoPeriodHalfCycle = 5 Once AutoPeriodRaw = 10.001 Once AutoPeriodRounded = 10 Once HPFilter = 0 Once SSFilter = 0 If BarIndex > MinBarsRequired then // -> Roofing Filter // Highpass Filter cyclic components whose periods are shorter than CycleMax bars HPAlpha = (Cos(0.707 * 360 / CycleMax) + Sin(0.707 * 360 / CycleMax) - 1) / Cos(0.707 * 360 / CycleMax) HPFilter = (1 - HPAlpha / 2) * (1 - HPAlpha / 2) * (Close - 2 * Close[1] + Close[2]) + 2 * (1 - HPAlpha) * HPFilter[1] - (1 - HPAlpha) * (1 - HPAlpha) * HPFilter[2] // Smooth with a Super Smoother Filter a1 = Exp(-1.414 * 3.14159 / CycleMin) b1 = 2 * a1 * Cos(1.414 * 180 / CycleMin) c2 = b1 c3 = -a1 * a1 c1 = 1 - c2 - c3 SSFilter = c1 * (HPFilter + HPFilter[1]) / 2 + c2 * SSFilter[1] + c3 * SSFilter[2] SmoothPrice = SSFilter // -> Pearson Correlation (PC for each value of lag) For LagCount = 0 to CycleMax // Set the averaging length as M M = AvgLength If (AvgLength < 1) or (AvgLength > 3) then M = 3 EndIf Sx = 0 Sy = 0 Sxx = 0 Syy = 0 Sxy = 0 If (M > 0) then X = SmoothPrice[0] Y = SmoothPrice[LagCount + 0] Sx = Sx + X Sy = Sy + Y Sxx = Sxx + X * X Sxy = Sxy + X * Y Syy = Syy + Y * Y EndIf If (M > 1) then X = SmoothPrice[1] Y = SmoothPrice[LagCount + 1] Sx = Sx + X Sy = Sy + Y Sxx = Sxx + X * X Sxy = Sxy + X * Y Syy = Syy + Y * Y EndIf If (M > 2) then X = SmoothPrice[2] Y = SmoothPrice[LagCount + 2] Sx = Sx + X Sy = Sy + Y Sxx = Sxx + X * X Sxy = Sxy + X * Y Syy = Syy + Y * Y EndIf If (M * Sxx - Sx * Sx) * (M * Syy - Sy * Sy) > 0 then If LagCount = 0 then PearsonCorrelation0 = (M * Sxy - Sx * Sy) / Sqrt((M * Sxx - Sx * Sx) * (M * Syy - Sy * Sy)) ElsIf LagCount = 1 then PearsonCorrelation1 = (M * Sxy - Sx * Sy) / Sqrt((M * Sxx - Sx * Sx) * (M * Syy - Sy * Sy)) ElsIf LagCount = 2 then PearsonCorrelation2 = (M * Sxy - Sx * Sy) / Sqrt((M * Sxx - Sx * Sx) * (M * Syy - Sy * Sy)) ElsIf LagCount = 3 then PearsonCorrelation3 = (M * Sxy - Sx * Sy) / Sqrt((M * Sxx - Sx * Sx) * (M * Syy - Sy * Sy)) ElsIf LagCount = 4 then PearsonCorrelation4 = (M * Sxy - Sx * Sy) / Sqrt((M * Sxx - Sx * Sx) * (M * Syy - Sy * Sy)) ElsIf LagCount = 5 then PearsonCorrelation5 = (M * Sxy - Sx * Sy) / Sqrt((M * Sxx - Sx * Sx) * (M * Syy - Sy * Sy)) ElsIf LagCount = 6 then PearsonCorrelation6 = (M * Sxy - Sx * Sy) / Sqrt((M * Sxx - Sx * Sx) * (M * Syy - Sy * Sy)) ElsIf LagCount = 7 then PearsonCorrelation7 = (M * Sxy - Sx * Sy) / Sqrt((M * Sxx - Sx * Sx) * (M * Syy - Sy * Sy)) ElsIf LagCount = 8 then PearsonCorrelation8 = (M * Sxy - Sx * Sy) / Sqrt((M * Sxx - Sx * Sx) * (M * Syy - Sy * Sy)) ElsIf LagCount = 9 then PearsonCorrelation9 = (M * Sxy - Sx * Sy) / Sqrt((M * Sxx - Sx * Sx) * (M * Syy - Sy * Sy)) ElsIf LagCount = 10 then PearsonCorrelation10 = (M * Sxy - Sx * Sy) / Sqrt((M * Sxx - Sx * Sx) * (M * Syy - Sy * Sy)) ElsIf LagCount = 11 then PearsonCorrelation11 = (M * Sxy - Sx * Sy) / Sqrt((M * Sxx - Sx * Sx) * (M * Syy - Sy * Sy)) ElsIf LagCount = 12 then PearsonCorrelation12 = (M * Sxy - Sx * Sy) / Sqrt((M * Sxx - Sx * Sx) * (M * Syy - Sy * Sy)) ElsIf LagCount = 13 then PearsonCorrelation13 = (M * Sxy - Sx * Sy) / Sqrt((M * Sxx - Sx * Sx) * (M * Syy - Sy * Sy)) ElsIf LagCount = 14 then PearsonCorrelation14 = (M * Sxy - Sx * Sy) / Sqrt((M * Sxx - Sx * Sx) * (M * Syy - Sy * Sy)) ElsIf LagCount = 15 then PearsonCorrelation15 = (M * Sxy - Sx * Sy) / Sqrt((M * Sxx - Sx * Sx) * (M * Syy - Sy * Sy)) ElsIf LagCount = 16 then PearsonCorrelation16 = (M * Sxy - Sx * Sy) / Sqrt((M * Sxx - Sx * Sx) * (M * Syy - Sy * Sy)) ElsIf LagCount = 17 then PearsonCorrelation17 = (M * Sxy - Sx * Sy) / Sqrt((M * Sxx - Sx * Sx) * (M * Syy - Sy * Sy)) ElsIf LagCount = 18 then PearsonCorrelation18 = (M * Sxy - Sx * Sy) / Sqrt((M * Sxx - Sx * Sx) * (M * Syy - Sy * Sy)) ElsIf LagCount = 19 then PearsonCorrelation19 = (M * Sxy - Sx * Sy) / Sqrt((M * Sxx - Sx * Sx) * (M * Syy - Sy * Sy)) ElsIf LagCount = 20 then PearsonCorrelation20 = (M * Sxy - Sx * Sy) / Sqrt((M * Sxx - Sx * Sx) * (M * Syy - Sy * Sy)) ElsIf LagCount = 21 then PearsonCorrelation21 = (M * Sxy - Sx * Sy) / Sqrt((M * Sxx - Sx * Sx) * (M * Syy - Sy * Sy)) ElsIf LagCount = 22 then PearsonCorrelation22 = (M * Sxy - Sx * Sy) / Sqrt((M * Sxx - Sx * Sx) * (M * Syy - Sy * Sy)) ElsIf LagCount = 23 then PearsonCorrelation23 = (M * Sxy - Sx * Sy) / Sqrt((M * Sxx - Sx * Sx) * (M * Syy - Sy * Sy)) ElsIf LagCount = 24 then PearsonCorrelation24 = (M * Sxy - Sx * Sy) / Sqrt((M * Sxx - Sx * Sx) * (M * Syy - Sy * Sy)) ElsIf LagCount = 25 then PearsonCorrelation25 = (M * Sxy - Sx * Sy) / Sqrt((M * Sxx - Sx * Sx) * (M * Syy - Sy * Sy)) ElsIf LagCount = 26 then PearsonCorrelation26 = (M * Sxy - Sx * Sy) / Sqrt((M * Sxx - Sx * Sx) * (M * Syy - Sy * Sy)) ElsIf LagCount = 27 then PearsonCorrelation27 = (M * Sxy - Sx * Sy) / Sqrt((M * Sxx - Sx * Sx) * (M * Syy - Sy * Sy)) ElsIf LagCount = 28 then PearsonCorrelation28 = (M * Sxy - Sx * Sy) / Sqrt((M * Sxx - Sx * Sx) * (M * Syy - Sy * Sy)) ElsIf LagCount = 29 then PearsonCorrelation29 = (M * Sxy - Sx * Sy) / Sqrt((M * Sxx - Sx * Sx) * (M * Syy - Sy * Sy)) ElsIf LagCount = 30 then PearsonCorrelation30 = (M * Sxy - Sx * Sy) / Sqrt((M * Sxx - Sx * Sx) * (M * Syy - Sy * Sy)) ElsIf LagCount = 31 then PearsonCorrelation31 = (M * Sxy - Sx * Sy) / Sqrt((M * Sxx - Sx * Sx) * (M * Syy - Sy * Sy)) ElsIf LagCount = 32 then PearsonCorrelation32 = (M * Sxy - Sx * Sy) / Sqrt((M * Sxx - Sx * Sx) * (M * Syy - Sy * Sy)) ElsIf LagCount = 33 then PearsonCorrelation33 = (M * Sxy - Sx * Sy) / Sqrt((M * Sxx - Sx * Sx) * (M * Syy - Sy * Sy)) ElsIf LagCount = 34 then PearsonCorrelation34 = (M * Sxy - Sx * Sy) / Sqrt((M * Sxx - Sx * Sx) * (M * Syy - Sy * Sy)) ElsIf LagCount = 35 then PearsonCorrelation35 = (M * Sxy - Sx * Sy) / Sqrt((M * Sxx - Sx * Sx) * (M * Syy - Sy * Sy)) ElsIf LagCount = 36 then PearsonCorrelation36 = (M * Sxy - Sx * Sy) / Sqrt((M * Sxx - Sx * Sx) * (M * Syy - Sy * Sy)) ElsIf LagCount = 37 then PearsonCorrelation37 = (M * Sxy - Sx * Sy) / Sqrt((M * Sxx - Sx * Sx) * (M * Syy - Sy * Sy)) ElsIf LagCount = 38 then PearsonCorrelation38 = (M * Sxy - Sx * Sy) / Sqrt((M * Sxx - Sx * Sx) * (M * Syy - Sy * Sy)) ElsIf LagCount = 39 then PearsonCorrelation39 = (M * Sxy - Sx * Sy) / Sqrt((M * Sxx - Sx * Sx) * (M * Syy - Sy * Sy)) ElsIf LagCount = 40 then PearsonCorrelation40 = (M * Sxy - Sx * Sy) / Sqrt((M * Sxx - Sx * Sx) * (M * Syy - Sy * Sy)) ElsIf LagCount = 41 then PearsonCorrelation41 = (M * Sxy - Sx * Sy) / Sqrt((M * Sxx - Sx * Sx) * (M * Syy - Sy * Sy)) ElsIf LagCount = 42 then PearsonCorrelation42 = (M * Sxy - Sx * Sy) / Sqrt((M * Sxx - Sx * Sx) * (M * Syy - Sy * Sy)) ElsIf LagCount = 43 then PearsonCorrelation43 = (M * Sxy - Sx * Sy) / Sqrt((M * Sxx - Sx * Sx) * (M * Syy - Sy * Sy)) ElsIf LagCount = 44 then PearsonCorrelation44 = (M * Sxy - Sx * Sy) / Sqrt((M * Sxx - Sx * Sx) * (M * Syy - Sy * Sy)) ElsIf LagCount = 45 then PearsonCorrelation45 = (M * Sxy - Sx * Sy) / Sqrt((M * Sxx - Sx * Sx) * (M * Syy - Sy * Sy)) ElsIf LagCount = 46 then PearsonCorrelation46 = (M * Sxy - Sx * Sy) / Sqrt((M * Sxx - Sx * Sx) * (M * Syy - Sy * Sy)) ElsIf LagCount = 47 then PearsonCorrelation47 = (M * Sxy - Sx * Sy) / Sqrt((M * Sxx - Sx * Sx) * (M * Syy - Sy * Sy)) ElsIf LagCount = 48 then PearsonCorrelation48 = (M * Sxy - Sx * Sy) / Sqrt((M * Sxx - Sx * Sx) * (M * Syy - Sy * Sy)) ElsIf LagCount = 49 then PearsonCorrelation49 = (M * Sxy - Sx * Sy) / Sqrt((M * Sxx - Sx * Sx) * (M * Syy - Sy * Sy)) ElsIf LagCount = 50 then PearsonCorrelation50 = (M * Sxy - Sx * Sy) / Sqrt((M * Sxx - Sx * Sx) * (M * Syy - Sy * Sy)) ElsIf LagCount = 51 then PearsonCorrelation51 = (M * Sxy - Sx * Sy) / Sqrt((M * Sxx - Sx * Sx) * (M * Syy - Sy * Sy)) ElsIf LagCount = 52 then PearsonCorrelation52 = (M * Sxy - Sx * Sy) / Sqrt((M * Sxx - Sx * Sx) * (M * Syy - Sy * Sy)) ElsIf LagCount = 53 then PearsonCorrelation53 = (M * Sxy - Sx * Sy) / Sqrt((M * Sxx - Sx * Sx) * (M * Syy - Sy * Sy)) ElsIf LagCount = 54 then PearsonCorrelation54 = (M * Sxy - Sx * Sy) / Sqrt((M * Sxx - Sx * Sx) * (M * Syy - Sy * Sy)) ElsIf LagCount = 55 then PearsonCorrelation55 = (M * Sxy - Sx * Sy) / Sqrt((M * Sxx - Sx * Sx) * (M * Syy - Sy * Sy)) ElsIf LagCount = 56 then PearsonCorrelation56 = (M * Sxy - Sx * Sy) / Sqrt((M * Sxx - Sx * Sx) * (M * Syy - Sy * Sy)) ElsIf LagCount = 57 then PearsonCorrelation57 = (M * Sxy - Sx * Sy) / Sqrt((M * Sxx - Sx * Sx) * (M * Syy - Sy * Sy)) ElsIf LagCount = 58 then PearsonCorrelation58 = (M * Sxy - Sx * Sy) / Sqrt((M * Sxx - Sx * Sx) * (M * Syy - Sy * Sy)) ElsIf LagCount = 59 then PearsonCorrelation59 = (M * Sxy - Sx * Sy) / Sqrt((M * Sxx - Sx * Sx) * (M * Syy - Sy * Sy)) ElsIf LagCount = 60 then PearsonCorrelation60 = (M * Sxy - Sx * Sy) / Sqrt((M * Sxx - Sx * Sx) * (M * Syy - Sy * Sy)) EndIf EndIf Next // -> Discrete Fourier Transform (Compute DFT for each correlation) For PeriodCount = CycleMin to CycleMax CosinePart = 0 SinePart = 0 If CycleMax <= 0 then // Unused CosinePart = CosinePart + PearsonCorrelation0 * Cos(360 * 0 / PeriodCount) SinePart = SinePart + PearsonCorrelation0 * Sin(360 * 0 / PeriodCount) EndIf If CycleMax <= 1 then // Unused CosinePart = CosinePart + PearsonCorrelation1 * Cos(360 * 1 / PeriodCount) SinePart = SinePart + PearsonCorrelation1 * Sin(360 * 1 / PeriodCount) EndIf If CycleMax <= 2 then // Unused CosinePart = CosinePart + PearsonCorrelation2 * Cos(360 * 2 / PeriodCount) SinePart = SinePart + PearsonCorrelation2 * Sin(360 * 2 / PeriodCount) EndIf If CycleMax >= 3 then CosinePart = CosinePart + PearsonCorrelation3 * Cos(360 * 3 / PeriodCount) SinePart = SinePart + PearsonCorrelation3 * Sin(360 * 3 / PeriodCount) EndIf If CycleMax >= 4 then CosinePart = CosinePart + PearsonCorrelation4 * Cos(360 * 4 / PeriodCount) SinePart = SinePart + PearsonCorrelation4 * Sin(360 * 4 / PeriodCount) EndIf If CycleMax >= 5 then CosinePart = CosinePart + PearsonCorrelation5 * Cos(360 * 5 / PeriodCount) SinePart = SinePart + PearsonCorrelation5 * Sin(360 * 5 / PeriodCount) EndIf If CycleMax >= 6 then CosinePart = CosinePart + PearsonCorrelation6 * Cos(360 * 6 / PeriodCount) SinePart = SinePart + PearsonCorrelation6 * Sin(360 * 6 / PeriodCount) EndIf If CycleMax >= 7 then CosinePart = CosinePart + PearsonCorrelation7 * Cos(360 * 7 / PeriodCount) SinePart = SinePart + PearsonCorrelation7 * Sin(360 * 7 / PeriodCount) EndIf If CycleMax >= 8 then CosinePart = CosinePart + PearsonCorrelation8 * Cos(360 * 8 / PeriodCount) SinePart = SinePart + PearsonCorrelation8 * Sin(360 * 8 / PeriodCount) EndIf If CycleMax >= 9 then CosinePart = CosinePart + PearsonCorrelation9 * Cos(360 * 9 / PeriodCount) SinePart = SinePart + PearsonCorrelation9 * Sin(360 * 9 / PeriodCount) EndIf If CycleMax >= 10 then CosinePart = CosinePart + PearsonCorrelation10 * Cos(360 * 10 / PeriodCount) SinePart = SinePart + PearsonCorrelation10 * Sin(360 * 10 / PeriodCount) EndIf If CycleMax >= 11 then CosinePart = CosinePart + PearsonCorrelation11 * Cos(360 * 11 / PeriodCount) SinePart = SinePart + PearsonCorrelation11 * Sin(360 * 11 / PeriodCount) EndIf If CycleMax >= 12 then CosinePart = CosinePart + PearsonCorrelation12 * Cos(360 * 12 / PeriodCount) SinePart = SinePart + PearsonCorrelation12 * Sin(360 * 12 / PeriodCount) EndIf If CycleMax >= 13 then CosinePart = CosinePart + PearsonCorrelation13 * Cos(360 * 13 / PeriodCount) SinePart = SinePart + PearsonCorrelation13 * Sin(360 * 13 / PeriodCount) EndIf If CycleMax >= 14 then CosinePart = CosinePart + PearsonCorrelation14 * Cos(360 * 14 / PeriodCount) SinePart = SinePart + PearsonCorrelation14 * Sin(360 * 14 / PeriodCount) EndIf If CycleMax >= 15 then CosinePart = CosinePart + PearsonCorrelation15 * Cos(360 * 15 / PeriodCount) SinePart = SinePart + PearsonCorrelation15 * Sin(360 * 15 / PeriodCount) EndIf If CycleMax >= 16 then CosinePart = CosinePart + PearsonCorrelation16 * Cos(360 * 16 / PeriodCount) SinePart = SinePart + PearsonCorrelation16 * Sin(360 * 16 / PeriodCount) EndIf If CycleMax >= 17 then CosinePart = CosinePart + PearsonCorrelation17 * Cos(360 * 17 / PeriodCount) SinePart = SinePart + PearsonCorrelation17 * Sin(360 * 17 / PeriodCount) EndIf If CycleMax >= 18 then CosinePart = CosinePart + PearsonCorrelation18 * Cos(360 * 18 / PeriodCount) SinePart = SinePart + PearsonCorrelation18 * Sin(360 * 18 / PeriodCount) EndIf If CycleMax >= 19 then CosinePart = CosinePart + PearsonCorrelation19 * Cos(360 * 19 / PeriodCount) SinePart = SinePart + PearsonCorrelation19 * Sin(360 * 19 / PeriodCount) EndIf If CycleMax >= 20 then CosinePart = CosinePart + PearsonCorrelation20 * Cos(360 * 20 / PeriodCount) SinePart = SinePart + PearsonCorrelation20 * Sin(360 * 20 / PeriodCount) EndIf If CycleMax >= 21 then CosinePart = CosinePart + PearsonCorrelation21 * Cos(360 * 21 / PeriodCount) SinePart = SinePart + PearsonCorrelation21 * Sin(360 * 21 / PeriodCount) EndIf If CycleMax >= 22 then CosinePart = CosinePart + PearsonCorrelation22 * Cos(360 * 22 / PeriodCount) SinePart = SinePart + PearsonCorrelation22 * Sin(360 * 22 / PeriodCount) EndIf If CycleMax >= 23 then CosinePart = CosinePart + PearsonCorrelation23 * Cos(360 * 23 / PeriodCount) SinePart = SinePart + PearsonCorrelation23 * Sin(360 * 23 / PeriodCount) EndIf If CycleMax >= 24 then CosinePart = CosinePart + PearsonCorrelation24 * Cos(360 * 24 / PeriodCount) SinePart = SinePart + PearsonCorrelation24 * Sin(360 * 24 / PeriodCount) EndIf If CycleMax >= 25 then CosinePart = CosinePart + PearsonCorrelation25 * Cos(360 * 25 / PeriodCount) SinePart = SinePart + PearsonCorrelation25 * Sin(360 * 25 / PeriodCount) EndIf If CycleMax >= 26 then CosinePart = CosinePart + PearsonCorrelation26 * Cos(360 * 26 / PeriodCount) SinePart = SinePart + PearsonCorrelation26 * Sin(360 * 26 / PeriodCount) EndIf If CycleMax >= 27 then CosinePart = CosinePart + PearsonCorrelation27 * Cos(360 * 27 / PeriodCount) SinePart = SinePart + PearsonCorrelation27 * Sin(360 * 27 / PeriodCount) EndIf If CycleMax >= 28 then CosinePart = CosinePart + PearsonCorrelation28 * Cos(360 * 28 / PeriodCount) SinePart = SinePart + PearsonCorrelation28 * Sin(360 * 28 / PeriodCount) EndIf If CycleMax >= 29 then CosinePart = CosinePart + PearsonCorrelation29 * Cos(360 * 29 / PeriodCount) SinePart = SinePart + PearsonCorrelation29 * Sin(360 * 29 / PeriodCount) EndIf If CycleMax >= 30 then CosinePart = CosinePart + PearsonCorrelation30 * Cos(360 * 30 / PeriodCount) SinePart = SinePart + PearsonCorrelation30 * Sin(360 * 30 / PeriodCount) EndIf If CycleMax >= 31 then CosinePart = CosinePart + PearsonCorrelation31 * Cos(360 * 31 / PeriodCount) SinePart = SinePart + PearsonCorrelation31 * Sin(360 * 31 / PeriodCount) EndIf If CycleMax >= 32 then CosinePart = CosinePart + PearsonCorrelation32 * Cos(360 * 32 / PeriodCount) SinePart = SinePart + PearsonCorrelation32 * Sin(360 * 32 / PeriodCount) EndIf If CycleMax >= 33 then CosinePart = CosinePart + PearsonCorrelation33 * Cos(360 * 33 / PeriodCount) SinePart = SinePart + PearsonCorrelation33 * Sin(360 * 33 / PeriodCount) EndIf If CycleMax >= 34 then CosinePart = CosinePart + PearsonCorrelation34 * Cos(360 * 34 / PeriodCount) SinePart = SinePart + PearsonCorrelation34 * Sin(360 * 34 / PeriodCount) EndIf If CycleMax >= 35 then CosinePart = CosinePart + PearsonCorrelation35 * Cos(360 * 35 / PeriodCount) SinePart = SinePart + PearsonCorrelation35 * Sin(360 * 35 / PeriodCount) EndIf If CycleMax >= 36 then CosinePart = CosinePart + PearsonCorrelation36 * Cos(360 * 36 / PeriodCount) SinePart = SinePart + PearsonCorrelation36 * Sin(360 * 36 / PeriodCount) EndIf If CycleMax >= 37 then CosinePart = CosinePart + PearsonCorrelation37 * Cos(360 * 37 / PeriodCount) SinePart = SinePart + PearsonCorrelation37 * Sin(360 * 37 / PeriodCount) EndIf If CycleMax >= 38 then CosinePart = CosinePart + PearsonCorrelation38 * Cos(360 * 38 / PeriodCount) SinePart = SinePart + PearsonCorrelation38 * Sin(360 * 38 / PeriodCount) EndIf If CycleMax >= 39 then CosinePart = CosinePart + PearsonCorrelation39 * Cos(360 * 39 / PeriodCount) SinePart = SinePart + PearsonCorrelation39 * Sin(360 * 39 / PeriodCount) EndIf If CycleMax >= 40 then CosinePart = CosinePart + PearsonCorrelation40 * Cos(360 * 40 / PeriodCount) SinePart = SinePart + PearsonCorrelation40 * Sin(360 * 40 / PeriodCount) EndIf If CycleMax >= 41 then CosinePart = CosinePart + PearsonCorrelation41 * Cos(360 * 41 / PeriodCount) SinePart = SinePart + PearsonCorrelation41 * Sin(360 * 41 / PeriodCount) EndIf If CycleMax >= 42 then CosinePart = CosinePart + PearsonCorrelation42 * Cos(360 * 42 / PeriodCount) SinePart = SinePart + PearsonCorrelation42 * Sin(360 * 42 / PeriodCount) EndIf If CycleMax >= 43 then CosinePart = CosinePart + PearsonCorrelation43 * Cos(360 * 43 / PeriodCount) SinePart = SinePart + PearsonCorrelation43 * Sin(360 * 43 / PeriodCount) EndIf If CycleMax >= 44 then CosinePart = CosinePart + PearsonCorrelation44 * Cos(360 * 44 / PeriodCount) SinePart = SinePart + PearsonCorrelation44 * Sin(360 * 44 / PeriodCount) EndIf If CycleMax >= 45 then CosinePart = CosinePart + PearsonCorrelation45 * Cos(360 * 45 / PeriodCount) SinePart = SinePart + PearsonCorrelation45 * Sin(360 * 45 / PeriodCount) EndIf If CycleMax >= 46 then CosinePart = CosinePart + PearsonCorrelation46 * Cos(360 * 46 / PeriodCount) SinePart = SinePart + PearsonCorrelation46 * Sin(360 * 46 / PeriodCount) EndIf If CycleMax >= 47 then CosinePart = CosinePart + PearsonCorrelation47 * Cos(360 * 47 / PeriodCount) SinePart = SinePart + PearsonCorrelation47 * Sin(360 * 47 / PeriodCount) EndIf If CycleMax >= 48 then CosinePart = CosinePart + PearsonCorrelation48 * Cos(360 * 48 / PeriodCount) SinePart = SinePart + PearsonCorrelation48 * Sin(360 * 48 / PeriodCount) EndIf If CycleMax >= 49 then CosinePart = CosinePart + PearsonCorrelation49 * Cos(360 * 49 / PeriodCount) SinePart = SinePart + PearsonCorrelation49 * Sin(360 * 49 / PeriodCount) EndIf If CycleMax >= 50 then CosinePart = CosinePart + PearsonCorrelation50 * Cos(360 * 50 / PeriodCount) SinePart = SinePart + PearsonCorrelation50 * Sin(360 * 50 / PeriodCount) EndIf If CycleMax >= 51 then CosinePart = CosinePart + PearsonCorrelation51 * Cos(360 * 51 / PeriodCount) SinePart = SinePart + PearsonCorrelation51 * Sin(360 * 51 / PeriodCount) EndIf If CycleMax >= 52 then CosinePart = CosinePart + PearsonCorrelation52 * Cos(360 * 52 / PeriodCount) SinePart = SinePart + PearsonCorrelation52 * Sin(360 * 52 / PeriodCount) EndIf If CycleMax >= 53 then CosinePart = CosinePart + PearsonCorrelation53 * Cos(360 * 53 / PeriodCount) SinePart = SinePart + PearsonCorrelation53 * Sin(360 * 53 / PeriodCount) EndIf If CycleMax >= 54 then CosinePart = CosinePart + PearsonCorrelation54 * Cos(360 * 54 / PeriodCount) SinePart = SinePart + PearsonCorrelation54 * Sin(360 * 54 / PeriodCount) EndIf If CycleMax >= 55 then CosinePart = CosinePart + PearsonCorrelation55 * Cos(360 * 55 / PeriodCount) SinePart = SinePart + PearsonCorrelation55 * Sin(360 * 55 / PeriodCount) EndIf If CycleMax >= 56 then CosinePart = CosinePart + PearsonCorrelation56 * Cos(360 * 56 / PeriodCount) SinePart = SinePart + PearsonCorrelation56 * Sin(360 * 56 / PeriodCount) EndIf If CycleMax >= 57 then CosinePart = CosinePart + PearsonCorrelation57 * Cos(360 * 57 / PeriodCount) SinePart = SinePart + PearsonCorrelation57 * Sin(360 * 57 / PeriodCount) EndIf If CycleMax >= 58 then CosinePart = CosinePart + PearsonCorrelation58 * Cos(360 * 58 / PeriodCount) SinePart = SinePart + PearsonCorrelation58 * Sin(360 * 58 / PeriodCount) EndIf If CycleMax >= 59 then CosinePart = CosinePart + PearsonCorrelation59 * Cos(360 * 59 / PeriodCount) SinePart = SinePart + PearsonCorrelation59 * Sin(360 * 59 / PeriodCount) EndIf If CycleMax >= 60 then CosinePart = CosinePart + PearsonCorrelation60 * Cos(360 * 60 / PeriodCount) SinePart = SinePart + PearsonCorrelation60 * Sin(360 * 60 / PeriodCount) EndIf // Sum CosinePart And SinePart Square If PeriodCount = 0 then SquareSum0 = CosinePart * CosinePart + SinePart * SinePart ElsIf PeriodCount = 1 then SquareSum1 = CosinePart * CosinePart + SinePart * SinePart ElsIf PeriodCount = 2 then SquareSum2 = CosinePart * CosinePart + SinePart * SinePart ElsIf PeriodCount = 3 then SquareSum3 = CosinePart * CosinePart + SinePart * SinePart ElsIf PeriodCount = 4 then SquareSum4 = CosinePart * CosinePart + SinePart * SinePart ElsIf PeriodCount = 5 then SquareSum5 = CosinePart * CosinePart + SinePart * SinePart ElsIf PeriodCount = 6 then SquareSum6 = CosinePart * CosinePart + SinePart * SinePart ElsIf PeriodCount = 7 then SquareSum7 = CosinePart * CosinePart + SinePart * SinePart ElsIf PeriodCount = 8 then SquareSum8 = CosinePart * CosinePart + SinePart * SinePart ElsIf PeriodCount = 9 then SquareSum9 = CosinePart * CosinePart + SinePart * SinePart ElsIf PeriodCount = 10 then SquareSum10 = CosinePart * CosinePart + SinePart * SinePart ElsIf PeriodCount = 11 then SquareSum11 = CosinePart * CosinePart + SinePart * SinePart ElsIf PeriodCount = 12 then SquareSum12 = CosinePart * CosinePart + SinePart * SinePart ElsIf PeriodCount = 13 then SquareSum13 = CosinePart * CosinePart + SinePart * SinePart ElsIf PeriodCount = 14 then SquareSum14 = CosinePart * CosinePart + SinePart * SinePart ElsIf PeriodCount = 15 then SquareSum15 = CosinePart * CosinePart + SinePart * SinePart ElsIf PeriodCount = 16 then SquareSum16 = CosinePart * CosinePart + SinePart * SinePart ElsIf PeriodCount = 17 then SquareSum17 = CosinePart * CosinePart + SinePart * SinePart ElsIf PeriodCount = 18 then SquareSum18 = CosinePart * CosinePart + SinePart * SinePart ElsIf PeriodCount = 19 then SquareSum19 = CosinePart * CosinePart + SinePart * SinePart ElsIf PeriodCount = 20 then SquareSum20 = CosinePart * CosinePart + SinePart * SinePart ElsIf PeriodCount = 21 then SquareSum21 = CosinePart * CosinePart + SinePart * SinePart ElsIf PeriodCount = 22 then SquareSum22 = CosinePart * CosinePart + SinePart * SinePart ElsIf PeriodCount = 23 then SquareSum23 = CosinePart * CosinePart + SinePart * SinePart ElsIf PeriodCount = 24 then SquareSum24 = CosinePart * CosinePart + SinePart * SinePart ElsIf PeriodCount = 25 then SquareSum25 = CosinePart * CosinePart + SinePart * SinePart ElsIf PeriodCount = 26 then SquareSum26 = CosinePart * CosinePart + SinePart * SinePart ElsIf PeriodCount = 27 then SquareSum27 = CosinePart * CosinePart + SinePart * SinePart ElsIf PeriodCount = 28 then SquareSum28 = CosinePart * CosinePart + SinePart * SinePart ElsIf PeriodCount = 29 then SquareSum29 = CosinePart * CosinePart + SinePart * SinePart ElsIf PeriodCount = 30 then SquareSum30 = CosinePart * CosinePart + SinePart * SinePart ElsIf PeriodCount = 31 then SquareSum31 = CosinePart * CosinePart + SinePart * SinePart ElsIf PeriodCount = 32 then SquareSum32 = CosinePart * CosinePart + SinePart * SinePart ElsIf PeriodCount = 33 then SquareSum33 = CosinePart * CosinePart + SinePart * SinePart ElsIf PeriodCount = 34 then SquareSum34 = CosinePart * CosinePart + SinePart * SinePart ElsIf PeriodCount = 35 then SquareSum35 = CosinePart * CosinePart + SinePart * SinePart ElsIf PeriodCount = 36 then SquareSum36 = CosinePart * CosinePart + SinePart * SinePart ElsIf PeriodCount = 37 then SquareSum37 = CosinePart * CosinePart + SinePart * SinePart ElsIf PeriodCount = 38 then SquareSum38 = CosinePart * CosinePart + SinePart * SinePart ElsIf PeriodCount = 39 then SquareSum39 = CosinePart * CosinePart + SinePart * SinePart ElsIf PeriodCount = 40 then SquareSum40 = CosinePart * CosinePart + SinePart * SinePart ElsIf PeriodCount = 41 then SquareSum41 = CosinePart * CosinePart + SinePart * SinePart ElsIf PeriodCount = 42 then SquareSum42 = CosinePart * CosinePart + SinePart * SinePart ElsIf PeriodCount = 43 then SquareSum43 = CosinePart * CosinePart + SinePart * SinePart ElsIf PeriodCount = 44 then SquareSum44 = CosinePart * CosinePart + SinePart * SinePart ElsIf PeriodCount = 45 then SquareSum45 = CosinePart * CosinePart + SinePart * SinePart ElsIf PeriodCount = 46 then SquareSum46 = CosinePart * CosinePart + SinePart * SinePart ElsIf PeriodCount = 47 then SquareSum47 = CosinePart * CosinePart + SinePart * SinePart ElsIf PeriodCount = 48 then SquareSum48 = CosinePart * CosinePart + SinePart * SinePart ElsIf PeriodCount = 49 then SquareSum49 = CosinePart * CosinePart + SinePart * SinePart ElsIf PeriodCount = 50 then SquareSum50 = CosinePart * CosinePart + SinePart * SinePart ElsIf PeriodCount = 51 then SquareSum51 = CosinePart * CosinePart + SinePart * SinePart ElsIf PeriodCount = 52 then SquareSum52 = CosinePart * CosinePart + SinePart * SinePart ElsIf PeriodCount = 53 then SquareSum53 = CosinePart * CosinePart + SinePart * SinePart ElsIf PeriodCount = 54 then SquareSum54 = CosinePart * CosinePart + SinePart * SinePart ElsIf PeriodCount = 55 then SquareSum55 = CosinePart * CosinePart + SinePart * SinePart ElsIf PeriodCount = 56 then SquareSum56 = CosinePart * CosinePart + SinePart * SinePart ElsIf PeriodCount = 57 then SquareSum57 = CosinePart * CosinePart + SinePart * SinePart ElsIf PeriodCount = 58 then SquareSum58 = CosinePart * CosinePart + SinePart * SinePart ElsIf PeriodCount = 59 then SquareSum59 = CosinePart * CosinePart + SinePart * SinePart ElsIf PeriodCount = 60 then SquareSum60 = CosinePart * CosinePart + SinePart * SinePart EndIf Next // -> Relative Power (Sum of DFT squared) For PeriodCount = CycleMin to CycleMax If PeriodCount = 0 then RR0 = R0 R0 = 0.2 * SquareSum0 * SquareSum0 + 0.8 * RR0 ElsIf PeriodCount = 1 then RR1 = R1 R1 = 0.2 * SquareSum1 * SquareSum1 + 0.8 * RR1 ElsIf PeriodCount = 2 then RR2 = R02 R02 = 0.2 * SquareSum2 * SquareSum2 + 0.8 * RR2 ElsIf PeriodCount = 3 then RR3 = R3 R3 = 0.2 * SquareSum3 * SquareSum3 + 0.8 * RR3 ElsIf PeriodCount = 4 then RR4 = R4 R4 = 0.2 * SquareSum4 * SquareSum4 + 0.8 * RR4 ElsIf PeriodCount = 5 then RR5 = R5 R5 = 0.2 * SquareSum5 * SquareSum5 + 0.8 * RR5 ElsIf PeriodCount = 6 then RR6 = R6 R6 = 0.2 * SquareSum6 * SquareSum6 + 0.8 * RR6 ElsIf PeriodCount = 7 then RR7 = R7 R7 = 0.2 * SquareSum7 * SquareSum7 + 0.8 * RR7 ElsIf PeriodCount = 8 then RR8 = R8 R8 = 0.2 * SquareSum8 * SquareSum8 + 0.8 * RR8 ElsIf PeriodCount = 9 then RR9 = R9 R9 = 0.2 * SquareSum9 * SquareSum9 + 0.8 * RR9 ElsIf PeriodCount = 10 then RR10 = R10 R10 = 0.2 * SquareSum10 * SquareSum10 + 0.8 * RR10 ElsIf PeriodCount = 11 then RR11 = R11 R11 = 0.2 * SquareSum11 * SquareSum11 + 0.8 * RR11 ElsIf PeriodCount = 12 then RR12 = R12 R12 = 0.2 * SquareSum12 * SquareSum12 + 0.8 * RR12 ElsIf PeriodCount = 13 then RR13 = R13 R13 = 0.2 * SquareSum13 * SquareSum13 + 0.8 * RR13 ElsIf PeriodCount = 14 then RR14 = R14 R14 = 0.2 * SquareSum14 * SquareSum14 + 0.8 * RR14 ElsIf PeriodCount = 15 then RR15 = R15 R15 = 0.2 * SquareSum15 * SquareSum15 + 0.8 * RR15 ElsIf PeriodCount = 16 then RR16 = R16 R16 = 0.2 * SquareSum16 * SquareSum16 + 0.8 * RR16 ElsIf PeriodCount = 17 then RR17 = R17 R17 = 0.2 * SquareSum17 * SquareSum17 + 0.8 * RR17 ElsIf PeriodCount = 18 then RR18 = R18 R18 = 0.2 * SquareSum18 * SquareSum18 + 0.8 * RR18 ElsIf PeriodCount = 19 then RR19 = R19 R19 = 0.2 * SquareSum19 * SquareSum19 + 0.8 * RR19 ElsIf PeriodCount = 20 then RR20 = R20 R20 = 0.2 * SquareSum20 * SquareSum20 + 0.8 * RR20 ElsIf PeriodCount = 21 then RR21 = R21 R21 = 0.2 * SquareSum21 * SquareSum21 + 0.8 * RR21 ElsIf PeriodCount = 22 then RR22 = R22 R22 = 0.2 * SquareSum22 * SquareSum22 + 0.8 * RR22 ElsIf PeriodCount = 23 then RR23 = R23 R23 = 0.2 * SquareSum23 * SquareSum23 + 0.8 * RR23 ElsIf PeriodCount = 24 then RR24 = R24 R24 = 0.2 * SquareSum24 * SquareSum24 + 0.8 * RR24 ElsIf PeriodCount = 25 then RR25 = R25 R25 = 0.2 * SquareSum25 * SquareSum25 + 0.8 * RR25 ElsIf PeriodCount = 26 then RR26 = R26 R26 = 0.2 * SquareSum26 * SquareSum26 + 0.8 * RR26 ElsIf PeriodCount = 27 then RR27 = R27 R27 = 0.2 * SquareSum27 * SquareSum27 + 0.8 * RR27 ElsIf PeriodCount = 28 then RR28 = R28 R28 = 0.2 * SquareSum28 * SquareSum28 + 0.8 * RR28 ElsIf PeriodCount = 29 then RR29 = R29 R29 = 0.2 * SquareSum29 * SquareSum29 + 0.8 * RR29 ElsIf PeriodCount = 30 then RR30 = R30 R30 = 0.2 * SquareSum30 * SquareSum30 + 0.8 * RR30 ElsIf PeriodCount = 31 then RR31 = R31 R31 = 0.2 * SquareSum31 * SquareSum31 + 0.8 * RR31 ElsIf PeriodCount = 32 then RR32 = R32 R32 = 0.2 * SquareSum32 * SquareSum32 + 0.8 * RR32 ElsIf PeriodCount = 33 then RR33 = R33 R33 = 0.2 * SquareSum33 * SquareSum33 + 0.8 * RR33 ElsIf PeriodCount = 34 then RR34 = R34 R34 = 0.2 * SquareSum34 * SquareSum34 + 0.8 * RR34 ElsIf PeriodCount = 35 then RR35 = R35 R35 = 0.2 * SquareSum35 * SquareSum35 + 0.8 * RR35 ElsIf PeriodCount = 36 then RR36 = R36 R36 = 0.2 * SquareSum36 * SquareSum36 + 0.8 * RR36 ElsIf PeriodCount = 37 then RR37 = R37 R37 = 0.2 * SquareSum37 * SquareSum37 + 0.8 * RR37 ElsIf PeriodCount = 38 then RR38 = R38 R38 = 0.2 * SquareSum38 * SquareSum38 + 0.8 * RR38 ElsIf PeriodCount = 39 then RR39 = R39 R39 = 0.2 * SquareSum39 * SquareSum39 + 0.8 * RR39 ElsIf PeriodCount = 40 then RR40 = R40 R40 = 0.2 * SquareSum40 * SquareSum40 + 0.8 * RR40 ElsIf PeriodCount = 41 then RR41 = R41 R41 = 0.2 * SquareSum41 * SquareSum41 + 0.8 * RR41 ElsIf PeriodCount = 42 then RR42 = R42 R42 = 0.2 * SquareSum42 * SquareSum42 + 0.8 * RR42 ElsIf PeriodCount = 43 then RR43 = R43 R43 = 0.2 * SquareSum43 * SquareSum43 + 0.8 * RR43 ElsIf PeriodCount = 44 then RR44 = R44 R44 = 0.2 * SquareSum44 * SquareSum44 + 0.8 * RR44 ElsIf PeriodCount = 45 then RR45 = R45 R45 = 0.2 * SquareSum45 * SquareSum45 + 0.8 * RR45 ElsIf PeriodCount = 46 then RR46 = R46 R46 = 0.2 * SquareSum46 * SquareSum46 + 0.8 * RR46 ElsIf PeriodCount = 47 then RR47 = R47 R47 = 0.2 * SquareSum47 * SquareSum47 + 0.8 * RR47 ElsIf PeriodCount = 48 then RR48 = R48 R48 = 0.2 * SquareSum48 * SquareSum48 + 0.8 * RR48 ElsIf PeriodCount = 49 then RR49 = R49 R49 = 0.2 * SquareSum49 * SquareSum49 + 0.8 * RR49 ElsIf PeriodCount = 50 then RR50 = R50 R50 = 0.2 * SquareSum50 * SquareSum50 + 0.8 * RR50 ElsIf PeriodCount = 51 then RR51 = R51 R51 = 0.2 * SquareSum51 * SquareSum51 + 0.8 * RR51 ElsIf PeriodCount = 52 then RR52 = R52 R52 = 0.2 * SquareSum52 * SquareSum52 + 0.8 * RR52 ElsIf PeriodCount = 53 then RR53 = R53 R53 = 0.2 * SquareSum53 * SquareSum53 + 0.8 * RR53 ElsIf PeriodCount = 54 then RR54 = R54 R54 = 0.2 * SquareSum54 * SquareSum54 + 0.8 * RR54 ElsIf PeriodCount = 55 then RR55 = R55 R55 = 0.2 * SquareSum55 * SquareSum55 + 0.8 * RR55 ElsIf PeriodCount = 56 then RR56 = R56 R56 = 0.2 * SquareSum56 * SquareSum56 + 0.8 * RR56 ElsIf PeriodCount = 57 then RR57 = R57 R57 = 0.2 * SquareSum57 * SquareSum57 + 0.8 * RR57 ElsIf PeriodCount = 58 then RR58 = R58 R58 = 0.2 * SquareSum58 * SquareSum58 + 0.8 * RR58 ElsIf PeriodCount = 59 then RR59 = R59 R59 = 0.2 * SquareSum59 * SquareSum59 + 0.8 * RR59 ElsIf PeriodCount = 60 then RR60 = R60 R60 = 0.2 * SquareSum60 * SquareSum60 + 0.8 * RR60 EndIf Next If 1=2 then // 1=2 // -> Maximum Power Level For Normalization MaxPwr = 0 For PeriodCount = CycleMin to CycleMax If PeriodCount = 0 then If R0 > MaxPwr then MaxPwr = R0 EndIf ElsIf PeriodCount = 1 then If R1 > MaxPwr then MaxPwr = R1 EndIf ElsIf PeriodCount = 2 then If R02 > MaxPwr then MaxPwr = R02 EndIf ElsIf PeriodCount = 3 then If R3 > MaxPwr then MaxPwr = R3 EndIf ElsIf PeriodCount = 4 then If R4 > MaxPwr then MaxPwr = R4 EndIf ElsIf PeriodCount = 5 then If R5 > MaxPwr then MaxPwr = R5 EndIf ElsIf PeriodCount = 6 then If R6 > MaxPwr then MaxPwr = R6 EndIf ElsIf PeriodCount = 7 then If R7 > MaxPwr then MaxPwr = R7 EndIf ElsIf PeriodCount = 8 then If R8 > MaxPwr then MaxPwr = R8 EndIf ElsIf PeriodCount = 9 then If R9 > MaxPwr then MaxPwr = R9 EndIf ElsIf PeriodCount = 10 then If R10 > MaxPwr then MaxPwr = R10 EndIf ElsIf PeriodCount = 11 then If R11 > MaxPwr then MaxPwr = R11 EndIf ElsIf PeriodCount = 12 then If R12 > MaxPwr then MaxPwr = R12 EndIf ElsIf PeriodCount = 13 then If R13 > MaxPwr then MaxPwr = R13 EndIf ElsIf PeriodCount = 14 then If R14 > MaxPwr then MaxPwr = R14 EndIf ElsIf PeriodCount = 15 then If R15 > MaxPwr then MaxPwr = R15 EndIf ElsIf PeriodCount = 16 then If R16 > MaxPwr then MaxPwr = R16 EndIf ElsIf PeriodCount = 17 then If R17 > MaxPwr then MaxPwr = R17 EndIf ElsIf PeriodCount = 18 then If R18 > MaxPwr then MaxPwr = R18 EndIf ElsIf PeriodCount = 19 then If R19 > MaxPwr then MaxPwr = R19 EndIf ElsIf PeriodCount = 20 then If R20 > MaxPwr then MaxPwr = R20 EndIf ElsIf PeriodCount = 21 then If R21 > MaxPwr then MaxPwr = R21 EndIf ElsIf PeriodCount = 22 then If R22 > MaxPwr then MaxPwr = R22 EndIf ElsIf PeriodCount = 23 then If R23 > MaxPwr then MaxPwr = R23 EndIf ElsIf PeriodCount = 24 then If R24 > MaxPwr then MaxPwr = R24 EndIf ElsIf PeriodCount = 25 then If R25 > MaxPwr then MaxPwr = R25 EndIf ElsIf PeriodCount = 26 then If R26 > MaxPwr then MaxPwr = R26 EndIf ElsIf PeriodCount = 27 then If R27 > MaxPwr then MaxPwr = R27 EndIf ElsIf PeriodCount = 28 then If R28 > MaxPwr then MaxPwr = R28 EndIf ElsIf PeriodCount = 29 then If R29 > MaxPwr then MaxPwr = R29 EndIf ElsIf PeriodCount = 30 then If R30 > MaxPwr then MaxPwr = R30 EndIf ElsIf PeriodCount = 31 then If R31 > MaxPwr then MaxPwr = R31 EndIf ElsIf PeriodCount = 32 then If R32 > MaxPwr then MaxPwr = R32 EndIf ElsIf PeriodCount = 33 then If R33 > MaxPwr then MaxPwr = R33 EndIf ElsIf PeriodCount = 34 then If R34 > MaxPwr then MaxPwr = R34 EndIf ElsIf PeriodCount = 35 then If R35 > MaxPwr then MaxPwr = R35 EndIf ElsIf PeriodCount = 36 then If R36 > MaxPwr then MaxPwr = R36 EndIf ElsIf PeriodCount = 37 then If R37 > MaxPwr then MaxPwr = R37 EndIf ElsIf PeriodCount = 38 then If R38 > MaxPwr then MaxPwr = R38 EndIf ElsIf PeriodCount = 39 then If R39 > MaxPwr then MaxPwr = R39 EndIf ElsIf PeriodCount = 40 then If R40 > MaxPwr then MaxPwr = R40 EndIf ElsIf PeriodCount = 41 then If R41 > MaxPwr then MaxPwr = R41 EndIf ElsIf PeriodCount = 42 then If R42 > MaxPwr then MaxPwr = R42 EndIf ElsIf PeriodCount = 43 then If R43 > MaxPwr then MaxPwr = R43 EndIf ElsIf PeriodCount = 44 then If R44 > MaxPwr then MaxPwr = R44 EndIf ElsIf PeriodCount = 45 then If R45 > MaxPwr then MaxPwr = R45 EndIf ElsIf PeriodCount = 46 then If R46 > MaxPwr then MaxPwr = R46 EndIf ElsIf PeriodCount = 47 then If R47 > MaxPwr then MaxPwr = R47 EndIf ElsIf PeriodCount = 48 then If R48 > MaxPwr then MaxPwr = R48 EndIf ElsIf PeriodCount = 49 then If R49 > MaxPwr then MaxPwr = R49 EndIf ElsIf PeriodCount = 50 then If R50 > MaxPwr then MaxPwr = R50 EndIf ElsIf PeriodCount = 51 then If R51 > MaxPwr then MaxPwr = R51 EndIf ElsIf PeriodCount = 52 then If R52 > MaxPwr then MaxPwr = R52 EndIf ElsIf PeriodCount = 53 then If R53 > MaxPwr then MaxPwr = R53 EndIf ElsIf PeriodCount = 54 then If R54 > MaxPwr then MaxPwr = R54 EndIf ElsIf PeriodCount = 55 then If R55 > MaxPwr then MaxPwr = R55 EndIf ElsIf PeriodCount = 56 then If R56 > MaxPwr then MaxPwr = R56 EndIf ElsIf PeriodCount = 57 then If R57 > MaxPwr then MaxPwr = R57 EndIf ElsIf PeriodCount = 58 then If R58 > MaxPwr then MaxPwr = R58 EndIf ElsIf PeriodCount = 59 then If R59 > MaxPwr then MaxPwr = R59 EndIf ElsIf PeriodCount = 60 then If R60 > MaxPwr then MaxPwr = R60 EndIf EndIf Next // -> Automatic Gain Control (AGC Normalization) For PeriodCount = CycleMin to CycleMax If PeriodCount = 0 then Pwr0 = R0 / MaxPwr ElsIf PeriodCount = 1 then Pwr1 = R1 / MaxPwr ElsIf PeriodCount = 2 then Pwr2 = R02 / MaxPwr ElsIf PeriodCount = 3 then Pwr3 = R3 / MaxPwr ElsIf PeriodCount = 4 then Pwr4 = R4 / MaxPwr ElsIf PeriodCount = 5 then Pwr5 = R5 / MaxPwr ElsIf PeriodCount = 6 then Pwr6 = R6 / MaxPwr ElsIf PeriodCount = 7 then Pwr7 = R7 / MaxPwr ElsIf PeriodCount = 8 then Pwr8 = R8 / MaxPwr ElsIf PeriodCount = 9 then Pwr9 = R9 / MaxPwr ElsIf PeriodCount = 10 then Pwr10 = R10 / MaxPwr ElsIf PeriodCount = 11 then Pwr11 = R11 / MaxPwr ElsIf PeriodCount = 12 then Pwr12 = R12 / MaxPwr ElsIf PeriodCount = 13 then Pwr13 = R13 / MaxPwr ElsIf PeriodCount = 14 then Pwr14 = R14 / MaxPwr ElsIf PeriodCount = 15 then Pwr15 = R15 / MaxPwr ElsIf PeriodCount = 16 then Pwr16 = R16 / MaxPwr ElsIf PeriodCount = 17 then Pwr17 = R17 / MaxPwr ElsIf PeriodCount = 18 then Pwr18 = R18 / MaxPwr ElsIf PeriodCount = 19 then Pwr19 = R19 / MaxPwr ElsIf PeriodCount = 20 then Pwr20 = R20 / MaxPwr ElsIf PeriodCount = 21 then Pwr21 = R21 / MaxPwr ElsIf PeriodCount = 22 then Pwr22 = R22 / MaxPwr ElsIf PeriodCount = 23 then Pwr23 = R23 / MaxPwr ElsIf PeriodCount = 24 then Pwr24 = R24 / MaxPwr ElsIf PeriodCount = 25 then Pwr25 = R25 / MaxPwr ElsIf PeriodCount = 26 then Pwr26 = R26 / MaxPwr ElsIf PeriodCount = 27 then Pwr27 = R27 / MaxPwr ElsIf PeriodCount = 28 then Pwr28 = R28 / MaxPwr ElsIf PeriodCount = 29 then Pwr29 = R29 / MaxPwr ElsIf PeriodCount = 30 then Pwr30 = R30 / MaxPwr ElsIf PeriodCount = 31 then Pwr31 = R31 / MaxPwr ElsIf PeriodCount = 32 then Pwr32 = R32 / MaxPwr ElsIf PeriodCount = 33 then Pwr33 = R33 / MaxPwr ElsIf PeriodCount = 34 then Pwr34 = R34 / MaxPwr ElsIf PeriodCount = 35 then Pwr35 = R35 / MaxPwr ElsIf PeriodCount = 36 then Pwr36 = R36 / MaxPwr ElsIf PeriodCount = 37 then Pwr37 = R37 / MaxPwr ElsIf PeriodCount = 38 then Pwr38 = R38 / MaxPwr ElsIf PeriodCount = 39 then Pwr39 = R39 / MaxPwr ElsIf PeriodCount = 40 then Pwr40 = R40 / MaxPwr ElsIf PeriodCount = 41 then Pwr41 = R41 / MaxPwr ElsIf PeriodCount = 42 then Pwr42 = R42 / MaxPwr ElsIf PeriodCount = 43 then Pwr43 = R43 / MaxPwr ElsIf PeriodCount = 44 then Pwr44 = R44 / MaxPwr ElsIf PeriodCount = 45 then Pwr45 = R45 / MaxPwr ElsIf PeriodCount = 46 then Pwr46 = R46 / MaxPwr ElsIf PeriodCount = 47 then Pwr47 = R47 / MaxPwr ElsIf PeriodCount = 48 then Pwr48 = R48 / MaxPwr ElsIf PeriodCount = 49 then Pwr49 = R49 / MaxPwr ElsIf PeriodCount = 50 then Pwr50 = R50 / MaxPwr ElsIf PeriodCount = 51 then Pwr51 = R51 / MaxPwr ElsIf PeriodCount = 52 then Pwr52 = R52 / MaxPwr ElsIf PeriodCount = 53 then Pwr53 = R53 / MaxPwr ElsIf PeriodCount = 54 then Pwr54 = R54 / MaxPwr ElsIf PeriodCount = 55 then Pwr55 = R55 / MaxPwr ElsIf PeriodCount = 56 then Pwr56 = R56 / MaxPwr ElsIf PeriodCount = 57 then Pwr57 = R57 / MaxPwr ElsIf PeriodCount = 58 then Pwr58 = R58 / MaxPwr ElsIf PeriodCount = 59 then Pwr59 = R59 / MaxPwr ElsIf PeriodCount = 60 then Pwr60 = R60 / MaxPwr EndIf Next // -> Enhance Display Resolution If (EnhanceResolution) then For PeriodCount = CycleMin to CycleMax If PeriodCount = 0 then Pwr0 = Pwr0 * Pwr0 * Pwr0 ElsIf PeriodCount = 1 then Pwr1 = Pwr1 * Pwr1 * Pwr1 ElsIf PeriodCount = 2 then Pwr2 = Pwr2 * Pwr2 * Pwr2 ElsIf PeriodCount = 3 then Pwr3 = Pwr3 * Pwr3 * Pwr3 ElsIf PeriodCount = 4 then Pwr4 = Pwr4 * Pwr4 * Pwr4 ElsIf PeriodCount = 5 then Pwr5 = Pwr5 * Pwr5 * Pwr5 ElsIf PeriodCount = 6 then Pwr6 = Pwr6 * Pwr6 * Pwr6 ElsIf PeriodCount = 7 then Pwr7 = Pwr7 * Pwr7 * Pwr7 ElsIf PeriodCount = 8 then Pwr8 = Pwr8 * Pwr8 * Pwr8 ElsIf PeriodCount = 9 then Pwr9 = Pwr9 * Pwr9 * Pwr9 ElsIf PeriodCount = 10 then Pwr10 = Pwr10 * Pwr10 * Pwr10 ElsIf PeriodCount = 11 then Pwr11 = Pwr11 * Pwr11 * Pwr11 ElsIf PeriodCount = 12 then Pwr12 = Pwr12 * Pwr12 * Pwr12 ElsIf PeriodCount = 13 then Pwr13 = Pwr13 * Pwr13 * Pwr13 ElsIf PeriodCount = 14 then Pwr14 = Pwr14 * Pwr14 * Pwr14 ElsIf PeriodCount = 15 then Pwr15 = Pwr15 * Pwr15 * Pwr15 ElsIf PeriodCount = 16 then Pwr16 = Pwr16 * Pwr16 * Pwr16 ElsIf PeriodCount = 17 then Pwr17 = Pwr17 * Pwr17 * Pwr17 ElsIf PeriodCount = 18 then Pwr18 = Pwr18 * Pwr18 * Pwr18 ElsIf PeriodCount = 19 then Pwr19 = Pwr19 * Pwr19 * Pwr19 ElsIf PeriodCount = 20 then Pwr20 = Pwr20 * Pwr20 * Pwr20 ElsIf PeriodCount = 21 then Pwr21 = Pwr21 * Pwr21 * Pwr21 ElsIf PeriodCount = 22 then Pwr22 = Pwr22 * Pwr22 * Pwr22 ElsIf PeriodCount = 23 then Pwr23 = Pwr23 * Pwr23 * Pwr23 ElsIf PeriodCount = 24 then Pwr24 = Pwr24 * Pwr24 * Pwr24 ElsIf PeriodCount = 25 then Pwr25 = Pwr25 * Pwr25 * Pwr25 ElsIf PeriodCount = 26 then Pwr26 = Pwr26 * Pwr26 * Pwr26 ElsIf PeriodCount = 27 then Pwr27 = Pwr27 * Pwr27 * Pwr27 ElsIf PeriodCount = 28 then Pwr28 = Pwr28 * Pwr28 * Pwr28 ElsIf PeriodCount = 29 then Pwr29 = Pwr29 * Pwr29 * Pwr29 ElsIf PeriodCount = 30 then Pwr30 = Pwr30 * Pwr30 * Pwr30 ElsIf PeriodCount = 31 then Pwr31 = Pwr31 * Pwr31 * Pwr31 ElsIf PeriodCount = 32 then Pwr32 = Pwr32 * Pwr32 * Pwr32 ElsIf PeriodCount = 33 then Pwr33 = Pwr33 * Pwr33 * Pwr33 ElsIf PeriodCount = 34 then Pwr34 = Pwr34 * Pwr34 * Pwr34 ElsIf PeriodCount = 35 then Pwr35 = Pwr35 * Pwr35 * Pwr35 ElsIf PeriodCount = 36 then Pwr36 = Pwr36 * Pwr36 * Pwr36 ElsIf PeriodCount = 37 then Pwr37 = Pwr37 * Pwr37 * Pwr37 ElsIf PeriodCount = 38 then Pwr38 = Pwr38 * Pwr38 * Pwr38 ElsIf PeriodCount = 39 then Pwr39 = Pwr39 * Pwr39 * Pwr39 ElsIf PeriodCount = 40 then Pwr40 = Pwr40 * Pwr40 * Pwr40 ElsIf PeriodCount = 41 then Pwr41 = Pwr41 * Pwr41 * Pwr41 ElsIf PeriodCount = 42 then Pwr42 = Pwr42 * Pwr42 * Pwr42 ElsIf PeriodCount = 43 then Pwr43 = Pwr43 * Pwr43 * Pwr43 ElsIf PeriodCount = 44 then Pwr44 = Pwr44 * Pwr44 * Pwr44 ElsIf PeriodCount = 45 then Pwr45 = Pwr45 * Pwr45 * Pwr45 ElsIf PeriodCount = 46 then Pwr46 = Pwr46 * Pwr46 * Pwr46 ElsIf PeriodCount = 47 then Pwr47 = Pwr47 * Pwr47 * Pwr47 ElsIf PeriodCount = 48 then Pwr48 = Pwr48 * Pwr48 * Pwr48 ElsIf PeriodCount = 49 then Pwr49 = Pwr49 * Pwr49 * Pwr49 ElsIf PeriodCount = 50 then Pwr50 = Pwr50 * Pwr50 * Pwr50 ElsIf PeriodCount = 51 then Pwr51 = Pwr51 * Pwr51 * Pwr51 ElsIf PeriodCount = 52 then Pwr52 = Pwr52 * Pwr52 * Pwr52 ElsIf PeriodCount = 53 then Pwr53 = Pwr53 * Pwr53 * Pwr53 ElsIf PeriodCount = 54 then Pwr54 = Pwr54 * Pwr54 * Pwr54 ElsIf PeriodCount = 55 then Pwr55 = Pwr55 * Pwr55 * Pwr55 ElsIf PeriodCount = 56 then Pwr56 = Pwr56 * Pwr56 * Pwr56 ElsIf PeriodCount = 57 then Pwr57 = Pwr57 * Pwr57 * Pwr57 ElsIf PeriodCount = 58 then Pwr58 = Pwr58 * Pwr58 * Pwr58 ElsIf PeriodCount = 59 then Pwr59 = Pwr59 * Pwr59 * Pwr59 ElsIf PeriodCount = 60 then Pwr60 = Pwr60 * Pwr60 * Pwr60 EndIf Next EndIf // -> Dominant Cycle (Calculate using the Centre of Gravity of the spectrum) DominantCycle = 0 PeakPwr = 0 For PeriodCount = CycleMin to CycleMax If PeriodCount = 0 then If Pwr0 > PeakPwr then PeakPwr = Pwr0 EndIf ElsIf PeriodCount = 1 then If Pwr1 > PeakPwr then PeakPwr = Pwr1 EndIf ElsIf PeriodCount = 2 then If Pwr2 > PeakPwr then PeakPwr = Pwr2 EndIf ElsIf PeriodCount = 3 then If Pwr3 > PeakPwr then PeakPwr = Pwr3 EndIf ElsIf PeriodCount = 4 then If Pwr4 > PeakPwr then PeakPwr = Pwr4 EndIf ElsIf PeriodCount = 5 then If Pwr5 > PeakPwr then PeakPwr = Pwr5 EndIf ElsIf PeriodCount = 6 then If Pwr6 > PeakPwr then PeakPwr = Pwr6 EndIf ElsIf PeriodCount = 7 then If Pwr7 > PeakPwr then PeakPwr = Pwr7 EndIf ElsIf PeriodCount = 8 then If Pwr8 > PeakPwr then PeakPwr = Pwr8 EndIf ElsIf PeriodCount = 9 then If Pwr9 > PeakPwr then PeakPwr = Pwr9 EndIf ElsIf PeriodCount = 10 then If Pwr10 > PeakPwr then PeakPwr = Pwr10 EndIf ElsIf PeriodCount = 11 then If Pwr11 > PeakPwr then PeakPwr = Pwr11 EndIf ElsIf PeriodCount = 12 then If Pwr12 > PeakPwr then PeakPwr = Pwr12 EndIf ElsIf PeriodCount = 13 then If Pwr13 > PeakPwr then PeakPwr = Pwr13 EndIf ElsIf PeriodCount = 14 then If Pwr14 > PeakPwr then PeakPwr = Pwr14 EndIf ElsIf PeriodCount = 15 then If Pwr15 > PeakPwr then PeakPwr = Pwr15 EndIf ElsIf PeriodCount = 16 then If Pwr16 > PeakPwr then PeakPwr = Pwr16 EndIf ElsIf PeriodCount = 17 then If Pwr17 > PeakPwr then PeakPwr = Pwr17 EndIf ElsIf PeriodCount = 18 then If Pwr18 > PeakPwr then PeakPwr = Pwr18 EndIf ElsIf PeriodCount = 19 then If Pwr19 > PeakPwr then PeakPwr = Pwr19 EndIf ElsIf PeriodCount = 20 then If Pwr20 > PeakPwr then PeakPwr = Pwr20 EndIf ElsIf PeriodCount = 21 then If Pwr21 > PeakPwr then PeakPwr = Pwr21 EndIf ElsIf PeriodCount = 22 then If Pwr22 > PeakPwr then PeakPwr = Pwr22 EndIf ElsIf PeriodCount = 23 then If Pwr23 > PeakPwr then PeakPwr = Pwr23 EndIf ElsIf PeriodCount = 24 then If Pwr24 > PeakPwr then PeakPwr = Pwr24 EndIf ElsIf PeriodCount = 25 then If Pwr25 > PeakPwr then PeakPwr = Pwr25 EndIf ElsIf PeriodCount = 26 then If Pwr26 > PeakPwr then PeakPwr = Pwr26 EndIf ElsIf PeriodCount = 27 then If Pwr27 > PeakPwr then PeakPwr = Pwr27 EndIf ElsIf PeriodCount = 28 then If Pwr28 > PeakPwr then PeakPwr = Pwr28 EndIf ElsIf PeriodCount = 29 then If Pwr29 > PeakPwr then PeakPwr = Pwr29 EndIf ElsIf PeriodCount = 30 then If Pwr30 > PeakPwr then PeakPwr = Pwr30 EndIf ElsIf PeriodCount = 31 then If Pwr31 > PeakPwr then PeakPwr = Pwr31 EndIf ElsIf PeriodCount = 32 then If Pwr32 > PeakPwr then PeakPwr = Pwr32 EndIf ElsIf PeriodCount = 33 then If Pwr33 > PeakPwr then PeakPwr = Pwr33 EndIf ElsIf PeriodCount = 34 then If Pwr34 > PeakPwr then PeakPwr = Pwr34 EndIf ElsIf PeriodCount = 35 then If Pwr35 > PeakPwr then PeakPwr = Pwr35 EndIf ElsIf PeriodCount = 36 then If Pwr36 > PeakPwr then PeakPwr = Pwr36 EndIf ElsIf PeriodCount = 37 then If Pwr37 > PeakPwr then PeakPwr = Pwr37 EndIf ElsIf PeriodCount = 38 then If Pwr38 > PeakPwr then PeakPwr = Pwr38 EndIf ElsIf PeriodCount = 39 then If Pwr39 > PeakPwr then PeakPwr = Pwr39 EndIf ElsIf PeriodCount = 40 then If Pwr40 > PeakPwr then PeakPwr = Pwr40 EndIf ElsIf PeriodCount = 41 then If Pwr41 > PeakPwr then PeakPwr = Pwr41 EndIf ElsIf PeriodCount = 42 then If Pwr42 > PeakPwr then PeakPwr = Pwr42 EndIf ElsIf PeriodCount = 43 then If Pwr43 > PeakPwr then PeakPwr = Pwr43 EndIf ElsIf PeriodCount = 44 then If Pwr44 > PeakPwr then PeakPwr = Pwr44 EndIf ElsIf PeriodCount = 45 then If Pwr45 > PeakPwr then PeakPwr = Pwr45 EndIf ElsIf PeriodCount = 46 then If Pwr46 > PeakPwr then PeakPwr = Pwr46 EndIf ElsIf PeriodCount = 47 then If Pwr47 > PeakPwr then PeakPwr = Pwr47 EndIf ElsIf PeriodCount = 48 then If Pwr48 > PeakPwr then PeakPwr = Pwr48 EndIf ElsIf PeriodCount = 49 then If Pwr49 > PeakPwr then PeakPwr = Pwr49 EndIf ElsIf PeriodCount = 50 then If Pwr50 > PeakPwr then PeakPwr = Pwr50 EndIf ElsIf PeriodCount = 51 then If Pwr51 > PeakPwr then PeakPwr = Pwr51 EndIf ElsIf PeriodCount = 52 then If Pwr52 > PeakPwr then PeakPwr = Pwr52 EndIf ElsIf PeriodCount = 53 then If Pwr53 > PeakPwr then PeakPwr = Pwr53 EndIf ElsIf PeriodCount = 54 then If Pwr54 > PeakPwr then PeakPwr = Pwr54 EndIf ElsIf PeriodCount = 55 then If Pwr55 > PeakPwr then PeakPwr = Pwr55 EndIf ElsIf PeriodCount = 56 then If Pwr56 > PeakPwr then PeakPwr = Pwr56 EndIf ElsIf PeriodCount = 57 then If Pwr57 > PeakPwr then PeakPwr = Pwr57 EndIf ElsIf PeriodCount = 58 then If Pwr58 > PeakPwr then PeakPwr = Pwr58 EndIf ElsIf PeriodCount = 59 then If Pwr59 > PeakPwr then PeakPwr = Pwr59 EndIf ElsIf PeriodCount = 60 then If Pwr60 > PeakPwr then PeakPwr = Pwr60 EndIf EndIf Next Spx = 0 Sp = 0 For PeriodCount = CycleMin to CycleMax If PeriodCount = 0 then If PeakPwr >= 0.25 and Pwr0 >= 0.25 then Spx = Spx + PeriodCount * Pwr0 Sp = Sp + Pwr0 EndIf ElsIf PeriodCount = 1 then If PeakPwr >= 0.25 and Pwr1 >= 0.25 then Spx = Spx + PeriodCount * Pwr1 Sp = Sp + Pwr1 EndIf ElsIf PeriodCount = 2 then If PeakPwr >= 0.25 and Pwr2 >= 0.25 then Spx = Spx + PeriodCount * Pwr2 Sp = Sp + Pwr2 EndIf ElsIf PeriodCount = 3 then If PeakPwr >= 0.25 and Pwr3 >= 0.25 then Spx = Spx + PeriodCount * Pwr3 Sp = Sp + Pwr3 EndIf ElsIf PeriodCount = 4 then If PeakPwr >= 0.25 and Pwr4 >= 0.25 then Spx = Spx + PeriodCount * Pwr4 Sp = Sp + Pwr4 EndIf ElsIf PeriodCount = 5 then If PeakPwr >= 0.25 and Pwr5 >= 0.25 then Spx = Spx + PeriodCount * Pwr5 Sp = Sp + Pwr5 EndIf ElsIf PeriodCount = 6 then If PeakPwr >= 0.25 and Pwr6 >= 0.25 then Spx = Spx + PeriodCount * Pwr6 Sp = Sp + Pwr6 EndIf ElsIf PeriodCount = 7 then If PeakPwr >= 0.25 and Pwr7 >= 0.25 then Spx = Spx + PeriodCount * Pwr7 Sp = Sp + Pwr7 EndIf ElsIf PeriodCount = 8 then If PeakPwr >= 0.25 and Pwr8 >= 0.25 then Spx = Spx + PeriodCount * Pwr8 Sp = Sp + Pwr8 EndIf ElsIf PeriodCount = 9 then If PeakPwr >= 0.25 and Pwr9 >= 0.25 then Spx = Spx + PeriodCount * Pwr9 Sp = Sp + Pwr9 EndIf ElsIf PeriodCount = 10 then If PeakPwr >= 0.25 and Pwr10 >= 0.25 then Spx = Spx + PeriodCount * Pwr10 Sp = Sp + Pwr10 EndIf ElsIf PeriodCount = 11 then If PeakPwr >= 0.25 and Pwr11 >= 0.25 then Spx = Spx + PeriodCount * Pwr11 Sp = Sp + Pwr11 EndIf ElsIf PeriodCount = 12 then If PeakPwr >= 0.25 and Pwr12 >= 0.25 then Spx = Spx + PeriodCount * Pwr12 Sp = Sp + Pwr12 EndIf ElsIf PeriodCount = 13 then If PeakPwr >= 0.25 and Pwr13 >= 0.25 then Spx = Spx + PeriodCount * Pwr13 Sp = Sp + Pwr13 EndIf ElsIf PeriodCount = 14 then If PeakPwr >= 0.25 and Pwr14 >= 0.25 then Spx = Spx + PeriodCount * Pwr14 Sp = Sp + Pwr14 EndIf ElsIf PeriodCount = 15 then If PeakPwr >= 0.25 and Pwr15 >= 0.25 then Spx = Spx + PeriodCount * Pwr15 Sp = Sp + Pwr15 EndIf ElsIf PeriodCount = 16 then If PeakPwr >= 0.25 and Pwr16 >= 0.25 then Spx = Spx + PeriodCount * Pwr16 Sp = Sp + Pwr16 EndIf ElsIf PeriodCount = 17 then If PeakPwr >= 0.25 and Pwr17 >= 0.25 then Spx = Spx + PeriodCount * Pwr17 Sp = Sp + Pwr17 EndIf ElsIf PeriodCount = 18 then If PeakPwr >= 0.25 and Pwr18 >= 0.25 then Spx = Spx + PeriodCount * Pwr18 Sp = Sp + Pwr18 EndIf ElsIf PeriodCount = 19 then If PeakPwr >= 0.25 and Pwr19 >= 0.25 then Spx = Spx + PeriodCount * Pwr19 Sp = Sp + Pwr19 EndIf ElsIf PeriodCount = 20 then If PeakPwr >= 0.25 and Pwr20 >= 0.25 then Spx = Spx + PeriodCount * Pwr20 Sp = Sp + Pwr20 EndIf ElsIf PeriodCount = 21 then If PeakPwr >= 0.25 and Pwr21 >= 0.25 then Spx = Spx + PeriodCount * Pwr21 Sp = Sp + Pwr21 EndIf ElsIf PeriodCount = 22 then If PeakPwr >= 0.25 and Pwr22 >= 0.25 then Spx = Spx + PeriodCount * Pwr22 Sp = Sp + Pwr22 EndIf ElsIf PeriodCount = 23 then If PeakPwr >= 0.25 and Pwr23 >= 0.25 then Spx = Spx + PeriodCount * Pwr23 Sp = Sp + Pwr23 EndIf ElsIf PeriodCount = 24 then If PeakPwr >= 0.25 and Pwr24 >= 0.25 then Spx = Spx + PeriodCount * Pwr24 Sp = Sp + Pwr24 EndIf ElsIf PeriodCount = 25 then If PeakPwr >= 0.25 and Pwr25 >= 0.25 then Spx = Spx + PeriodCount * Pwr25 Sp = Sp + Pwr25 EndIf ElsIf PeriodCount = 26 then If PeakPwr >= 0.25 and Pwr26 >= 0.25 then Spx = Spx + PeriodCount * Pwr26 Sp = Sp + Pwr26 EndIf ElsIf PeriodCount = 27 then If PeakPwr >= 0.25 and Pwr27 >= 0.25 then Spx = Spx + PeriodCount * Pwr27 Sp = Sp + Pwr27 EndIf ElsIf PeriodCount = 28 then If PeakPwr >= 0.25 and Pwr28 >= 0.25 then Spx = Spx + PeriodCount * Pwr28 Sp = Sp + Pwr28 EndIf ElsIf PeriodCount = 29 then If PeakPwr >= 0.25 and Pwr29 >= 0.25 then Spx = Spx + PeriodCount * Pwr29 Sp = Sp + Pwr29 EndIf ElsIf PeriodCount = 30 then If PeakPwr >= 0.25 and Pwr30 >= 0.25 then Spx = Spx + PeriodCount * Pwr30 Sp = Sp + Pwr30 EndIf ElsIf PeriodCount = 31 then If PeakPwr >= 0.25 and Pwr31 >= 0.25 then Spx = Spx + PeriodCount * Pwr31 Sp = Sp + Pwr31 EndIf ElsIf PeriodCount = 32 then If PeakPwr >= 0.25 and Pwr32 >= 0.25 then Spx = Spx + PeriodCount * Pwr32 Sp = Sp + Pwr32 EndIf ElsIf PeriodCount = 33 then If PeakPwr >= 0.25 and Pwr33 >= 0.25 then Spx = Spx + PeriodCount * Pwr33 Sp = Sp + Pwr33 EndIf ElsIf PeriodCount = 34 then If PeakPwr >= 0.25 and Pwr34 >= 0.25 then Spx = Spx + PeriodCount * Pwr34 Sp = Sp + Pwr34 EndIf ElsIf PeriodCount = 35 then If PeakPwr >= 0.25 and Pwr35 >= 0.25 then Spx = Spx + PeriodCount * Pwr35 Sp = Sp + Pwr35 EndIf ElsIf PeriodCount = 36 then If PeakPwr >= 0.25 and Pwr36 >= 0.25 then Spx = Spx + PeriodCount * Pwr36 Sp = Sp + Pwr36 EndIf ElsIf PeriodCount = 37 then If PeakPwr >= 0.25 and Pwr37 >= 0.25 then Spx = Spx + PeriodCount * Pwr37 Sp = Sp + Pwr37 EndIf ElsIf PeriodCount = 38 then If PeakPwr >= 0.25 and Pwr38 >= 0.25 then Spx = Spx + PeriodCount * Pwr38 Sp = Sp + Pwr38 EndIf ElsIf PeriodCount = 39 then If PeakPwr >= 0.25 and Pwr39 >= 0.25 then Spx = Spx + PeriodCount * Pwr39 Sp = Sp + Pwr39 EndIf ElsIf PeriodCount = 40 then If PeakPwr >= 0.25 and Pwr40 >= 0.25 then Spx = Spx + PeriodCount * Pwr40 Sp = Sp + Pwr40 EndIf ElsIf PeriodCount = 41 then If PeakPwr >= 0.25 and Pwr41 >= 0.25 then Spx = Spx + PeriodCount * Pwr41 Sp = Sp + Pwr41 EndIf ElsIf PeriodCount = 42 then If PeakPwr >= 0.25 and Pwr42 >= 0.25 then Spx = Spx + PeriodCount * Pwr42 Sp = Sp + Pwr42 EndIf ElsIf PeriodCount = 43 then If PeakPwr >= 0.25 and Pwr43 >= 0.25 then Spx = Spx + PeriodCount * Pwr43 Sp = Sp + Pwr43 EndIf ElsIf PeriodCount = 44 then If PeakPwr >= 0.25 and Pwr44 >= 0.25 then Spx = Spx + PeriodCount * Pwr44 Sp = Sp + Pwr44 EndIf ElsIf PeriodCount = 45 then If PeakPwr >= 0.25 and Pwr45 >= 0.25 then Spx = Spx + PeriodCount * Pwr45 Sp = Sp + Pwr45 EndIf ElsIf PeriodCount = 46 then If PeakPwr >= 0.25 and Pwr46 >= 0.25 then Spx = Spx + PeriodCount * Pwr46 Sp = Sp + Pwr46 EndIf ElsIf PeriodCount = 47 then If PeakPwr >= 0.25 and Pwr47 >= 0.25 then Spx = Spx + PeriodCount * Pwr47 Sp = Sp + Pwr47 EndIf ElsIf PeriodCount = 48 then If PeakPwr >= 0.25 and Pwr48 >= 0.25 then Spx = Spx + PeriodCount * Pwr48 Sp = Sp + Pwr48 EndIf ElsIf PeriodCount = 49 then If PeakPwr >= 0.25 and Pwr49 >= 0.25 then Spx = Spx + PeriodCount * Pwr49 Sp = Sp + Pwr49 EndIf ElsIf PeriodCount = 50 then If PeakPwr >= 0.25 and Pwr50 >= 0.25 then Spx = Spx + PeriodCount * Pwr50 Sp = Sp + Pwr50 EndIf ElsIf PeriodCount = 51 then If PeakPwr >= 0.25 and Pwr51 >= 0.25 then Spx = Spx + PeriodCount * Pwr51 Sp = Sp + Pwr51 EndIf ElsIf PeriodCount = 52 then If PeakPwr >= 0.25 and Pwr52 >= 0.25 then Spx = Spx + PeriodCount * Pwr52 Sp = Sp + Pwr52 EndIf ElsIf PeriodCount = 53 then If PeakPwr >= 0.25 and Pwr53 >= 0.25 then Spx = Spx + PeriodCount * Pwr53 Sp = Sp + Pwr53 EndIf ElsIf PeriodCount = 54 then If PeakPwr >= 0.25 and Pwr54 >= 0.25 then Spx = Spx + PeriodCount * Pwr54 Sp = Sp + Pwr54 EndIf ElsIf PeriodCount = 55 then If PeakPwr >= 0.25 and Pwr55 >= 0.25 then Spx = Spx + PeriodCount * Pwr55 Sp = Sp + Pwr55 EndIf ElsIf PeriodCount = 56 then If PeakPwr >= 0.25 and Pwr56 >= 0.25 then Spx = Spx + PeriodCount * Pwr56 Sp = Sp + Pwr56 EndIf ElsIf PeriodCount = 57 then If PeakPwr >= 0.25 and Pwr57 >= 0.25 then Spx = Spx + PeriodCount * Pwr57 Sp = Sp + Pwr57 EndIf ElsIf PeriodCount = 58 then If PeakPwr >= 0.25 and Pwr58 >= 0.25 then Spx = Spx + PeriodCount * Pwr58 Sp = Sp + Pwr58 EndIf ElsIf PeriodCount = 59 then If PeakPwr >= 0.25 and Pwr59 >= 0.25 then Spx = Spx + PeriodCount * Pwr59 Sp = Sp + Pwr59 EndIf ElsIf PeriodCount = 60 then If PeakPwr >= 0.25 and Pwr60 >= 0.25 then Spx = Spx + PeriodCount * Pwr60 Sp = Sp + Pwr60 EndIf EndIf Next If Sp <> 0 then DominantCycle = Spx / Sp EndIf If Sp < 0.25 then DominantCycle = DominantCycle[1] EndIf If DominantCycle < 1 then DominantCycle = 1 EndIf AutoPeriodRaw = DominantCycle AutoPeriodDelta = AutoPeriodRaw - AutoPeriodRaw[1] AutoPeriodRounded = Round(AutoPeriodRaw) AutoPeriodHalfCycle = Round(AutoPeriodRaw / 2) AutoPeriodDelta = AutoPeriodDelta AutoPeriodRounded = AutoPeriodRounded AutoPeriodHalfCycle = AutoPeriodHalfCycle EndIf // 1=2 EndIf // Colours If (SmoothPrice > SmoothPrice[1]) then R = 0 G = 255 B = 153 ElsIf (SmoothPrice < SmoothPrice[1]) then R = 255 G = 102 B = 102 Else R = 255 G = 255 B = 255 EndIf Return SmoothPrice Coloured(R, G, B) as "SmoothPrice", AutoPeriodRaw Coloured(0, 153, 255) as "AutoPeriodRaw"