Phase change index by M.H. Pee as featured in TASC magazine.
Which phase is your market going through? Find out by using this indicator.
Prices at any time can be up, down, or unchanged. A period where market prices remain relatively unchanged is referred to as a consolidation. A period that witnesses relatively higher prices is referred to as an uptrend, while a period of relatively lower prices is called a downtrend.
The Phase Change Index (PCI) is an indicator designed specifically to detect changes in market phases.
The original indicator was not smoothed, in this version you can set a smoothing period to get a smoothed curve averaged with Jurik MA, easier to read (default is 30 periods). In the picture you can see a smoothed version (above) and the normal version (below).
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 |
//PRC_PhaseChangeIndex PCI | indicator //20.09.2018 //Nicolas @ www.prorealcode.com //Sharing ProRealTime knowledge //converted from MT5 version // --- settings inpLength = 30 // Phase change index period inpLevelHigh = 80 // Level high inpLevelLow = 20 // Level low inpSmooth = 30 // Smoothing Period inpInverted = 1 // Display type (1=inverted ; 0=normal) // --- end of settings prices = customclose imomentum = prices-prices[inpLength] sumUpDi = 0 sumDnDi = 0 for j=1 to inpLength-1 do gradient = prices[inpLength]+imomentum*(inpLength-j)/(inpLength) deviation = prices[j]-gradient if (deviation > 0) then sumUpDi = sumUpDi+deviation else sumDnDi = sumDnDi-deviation endif next //PCI calculation if sumUpDi+sumDnDi<>0 then val = 100.0*sumUpDi/(sumUpDi+sumDnDi) endif if inpInverted then val=100-val endif levdn = 50 if val>inpLevelHigh then levup = 100 elsif val<inpLevelLow then levup =0 else levup=50 endif //smoothing the PCI if inpSmooth>1 then Series=val Period=inpSmooth // Pow = 5 ({ 1..10 }) // R = 1.5 ({0.5..2.5}) Pow = 10 R = 2.5 beta = 0.45 * (Period - 1) / (0.45 * (Period - 1) + 2) IF Pow = 1 THEN alpha = beta ELSIF Pow = 2 THEN alpha = beta * beta ELSIF Pow = 3 THEN alpha = beta * beta * beta ELSIF Pow = 4 THEN alpha = beta * beta * beta * beta ELSIF Pow = 5 THEN alpha = beta * beta * beta * beta * beta ELSIF Pow = 6 THEN alpha = beta * beta * beta * beta * beta * beta ELSIF Pow = 7 THEN alpha = beta * beta * beta * beta * beta * beta * beta ELSIF Pow = 8 THEN alpha = beta * beta * beta * beta * beta * beta * beta * beta ELSIF Pow = 9 THEN alpha = beta * beta * beta * beta * beta * beta * beta * beta * beta ELSIF Pow = 10 THEN alpha = beta * beta * beta * beta * beta * beta * beta * beta * beta ENDIF IF BarIndex = 0 THEN Filt0 = Series Filt1 = Series AFR = Series ELSE Filt0 = (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] sval = AFR ENDIF else sval=val endif r=169 g=169 b=169 if sval>inpLevelHigh then r=0 g=191 b=255 endif if sval<inpLevelLow then r=244 g=164 b=96 endif return levup coloured(220,220,220,100) style(histogram) as "levup", levdn coloured(220,220,220) style(line,1) as "levdn", sval coloured(r,g,b) style(line,4) as "PCI", 80 coloured(192,192,192) style(dottedline) as "level 80", 20 coloured(192,192,192) style(dottedline) as "level 20" |
Share this
No information on this site is investment advice or a solicitation to buy or sell any financial instrument. Past performance is not indicative of future results. Trading may expose you to risk of loss greater than your deposits and is only suitable for experienced investors who have sufficient financial means to bear such risk.
ProRealTime ITF files and other attachments :PRC is also on YouTube, subscribe to our channel for exclusive content and tutorials
hello,
thank you for this code, I was wondering if it is compatible with thinkorswim at all?
No, but you can ask for private coding job at our programming services.