This indicator find market tops and bottoms with the use of the percentile rank of a derivated Laguerre oscillator. The market tops and bottoms are spotted with unique colors (green for bottoms and red for tops), when the oscillator cross over the extreme percentile rank (90%). The mid threshold lines could also act as warning that the price has reached a top or a bottom.
Fits well on a daily basis as ranking an oscillator value by its percentile rank is a good idea that can be explore in many other ways. Here is another path to follow for future research!
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 |
// parameters : // Short = 0.4 // Long = 0.8 // lkb = 200 (Look back period) // pctile = 90 (Extreme threshold lines) // midpctile = 70 (Warning threshold lines) if(barindex>lkb) then hl2 = (high+low)/2 //laguerre short Ls0 = (1 - Short)*hl2+Short*(Ls0[1]) Ls1 = -Short*Ls0+(Ls0[1])+Short*(Ls1[1]) Ls2 = -Short*Ls1+(Ls1[1])+Short*(Ls2[1]) Ls3 = -Short*Ls2+(Ls2[1])+Short*(Ls3[1]) lmas = (Ls0 + 2*Ls1 + 2*Ls2 + Ls3)/6 //laguerre long Ll0 = (1 - Long)*hl2+Long*(Ll0[1]) Ll1 = -Long*Ll0+(Ll0[1])+Long*(Ll1[1]) Ll2 = -Long*Ll1+(Ll1[1])+Long*(Ll2[1]) Ll3 = -Long*Ll2+(Ll2[1])+Long*(Ll3[1]) lmal = (Ll0 + 2*Ll1 + 2*Ll2 + Ll3)/6 pctileB = pctile * -1 //PPO Plot ppoT = (lmas-lmal)/lmal*100 ppoB = (lmal-lmas)/lmal*100 //PercentRank of PPO // percent rank = nb of value less than our value / (nb of values less than our value + nb of values greater than our value) topvalueMinus = 0 topvaluePlus = 0 bottomvalueMinus = 0 bottomvaluePlus = 0 for i = 0 to lkb do if ppoT[i]<ppoT then topvalueMinus = topvalueMinus+1 else topvaluePlus = topvaluePlus+1 endif if ppoB[i]<ppoB then bottomvalueMinus = bottomvalueMinus+1 else bottomvaluePlus = bottomvaluePlus+1 endif next pctRankT = topvalueMinus / (topvalueMinus+topvaluePlus) pctRankB = (bottomvalueMinus / (bottomvalueMinus+bottomvaluePlus)) *-1 //coloring histogram if pctRankT>=pctile/100 then TopColor = 1 else TopColor = -1 endif if pctRankB>=pctileB/100 then BottomColor = 1 else BottomColor = -1 endif endif RETURN pctRankT coloured by TopColor as "Top", pctRankB coloured by BottomColor as "Bottom", 0 as "zero line", pctile/100 as "Top Percentile Threshold", pctileB/100 as "Bottom Percentile Threshold", midpctile/100 as "Warning Top Percentile Threshold", (midpctile*-1)/100 as "Warning Bottom Percentile Threshold" |
This code is adapted from pinescript one by Chris Moody.
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
Thanks for converting this. Would be nice to see an updated version compatible for 10.3 mate.
Dear Nicolas,
I’ve been trying this indicator but unfortunately i can not get the settings right. I do not see the colors red and green like in your example. I’ve been trying several settings also with additional
colorzones but unfortunatley with no luck. Ive tried it on the 10.2 version from IG and on the 10.3 from PRT. I hope you can explain me what i’m doing wrong.
Thank you on forehand for your time.
Best regards,
Patrick
I
Yep, same here. It defaults to just lines in grey.
Just set “Top” positive color to red and “Bottom” negative color to green, every others returned variables set to grey by default.
Nic, any chance we could get an updated version for 10.3 please?This is a very solid indy for reversals.
Unfortunately that was the option i didn’t try. Thanks for the help, it works just fine now.
My chart is only in black and white I can’t get the color bars. Help me pleasse
Modified colors etc.
Hello everyone, I don’t understand the color setting. The indicator settings combo only allows you to have all the red or green bars or the part above the extreme percentile rank.
I tried to modify directly in the code the part as below but it does not run :
//coloring histogram
if pctRankT>=pctile/100 then
TopColor =(255,0,0)
else
TopColor =(204,204,204)
endif
if pctRankB>=pctileB/100 then
BottomColor = (255,0,255)
else
BottomColor = (204,204,204)
endif
endif
Hi Edisone, see my last comment for setting colors
If someone has an idea to help, many thanks for advance
Then I have tried this but nor does it run :
//coloring histogram
if pctRankT>=pctile/100 then
r=255
g=0
b=0
else
r=204
g=204
b=204
endif
if pctRankB>=pctileB/100 then
r=255
g=0
b=255
else
r=204
g=204
b=204
endif
endif
RETURN pctRankT coloured (r,g,b) as “Top”, pctRankB coloured (r,g,b) as “Bottom”, 0 as “zero line”, pctile/100 as “Top Percentile Threshold”, pctileB/100 as “Bottom Percentile Threshold”, midpctile/100 as “Warning Top Percentile Threshold”, (midpctile*-1)/100 as “Warning Bottom Percentile Threshold”
Here we are !
//coloring histogram
if pctRankT>=pctile/100 then
r=255
g=0
b=0
else
r=204
g=204
b=204
endif
if pctRankB<=pctileB/100 then
rr=0
gg=255
bb=0
else
rr=204
gg=204
bb=204
endif
endif
RETURN pctRankT coloured (r,g,b) as "Top", pctRankB coloured (rr,gg,bb) as "Bottom", 0 as "zero line", pctile/100 as "Top Percentile Threshold", pctileB/100 as "Bottom Percentile Threshold", midpctile/100 as "Warning Top Percentile Threshold", (midpctile*-1)/100 as "Warning Bottom Percentile Threshold"