//composite of 1996anoojpatels Futur modification of Fisher Transform Ribbons Indicator over a modifided (rescaled) version of evergets version of recursive median oscillator. I like them together // thanks to these great authors for bringing these indicators to trading view // //@version=3 // Copyright (c) 2018-present, Alex Orekhov (everget) // Recursive Median Oscillator indicator script may be freely distributed under the MIT license. study("Recursive Median Oscillator & Fisher Transforms Ribbon", shorttitle="RMO and FTR") medianLength = input(title="Length", type=integer, defval=5, minval=1) lowpassLength = input(title="Lowpass Length", type=integer, defval=12, minval=1) highpassLength = input(title="Highpass Length", type=integer, defval=30, minval=1) rmopeaklength = input(title="RMO Peak/Trough detect length", type=integer, defval=1000,minval=100) src = input(title="Source", type=source, defval=close) sort(src, i) => min = -10000.0 for j = 0 to i - 1 min_local = 10000.0 for l = 0 to medianLength - 1 if (nz(src[l]) <= min) continue min_local := min(min_local, max(min, nz(src[l]))) if min_local != 10000 min := min_local min median(src, length) => result = 0.0 if length % 2 == 0 result := (sort(src, length / 2) + sort(src, length / 2 + 1)) / 2 else result := sort(src, ceil(length / 2)) PI = 2 * asin(1) alpha1Arg = 2 * PI / lowpassLength alpha1 = (cos(alpha1Arg) + sin(alpha1Arg) - 1) / cos(alpha1Arg) rm = 0.0 rm := alpha1 * median(src, medianLength) + (1 - alpha1) * nz(rm[1]) alpha2Arg = 1 / sqrt(2) * 2 * PI / highpassLength alpha2 = (cos(alpha2Arg) + sin(alpha2Arg) - 1) / cos(alpha2Arg) rmo = 0.0 rmo := pow(1 - alpha2 / 2, 2) * (rm - 2 * nz(rm[1]) + nz(rm[2])) + 2 * (1 - alpha2) * nz(rmo[1]) - pow(1 - alpha2, 2) * nz(rmo[2]) //Detects highest and lowest so can rescale to meet other ranges a = highest(rmo,rmopeaklength) b = lowest(rmo,rmopeaklength) //plot(a, "a", #778899) //plot(b, "b", #556677) //rescale added by irenabyss from https://stats.stackexchange.com/questions/178626/how-to-normalize-data-between-1-and-1 s=sign(rmo) rescale_max=abs(a)>=abs(b)?abs(a):abs(b) rescale_amount=8/rescale_max rmo2=rmo*rescale_amount //rmo2=12*((rmo-b)/(a-b))-6 rmoColor = rmo >= 0.0 ? #778899 : #556677 //plot(rmo, title="RMO", linewidth=0, color=rmoColor, transp=60, style=area) plot(rmo2, title="RMO (grey) and MFTr", linewidth=1, color=rmoColor, transp=80, style=area) hline(0, title="Zero Level", linestyle=dashed, color=#3c78d8) // //Modified by mjb to include the Ehlers recursive median oscillator as background //////////////////////////////////////////////////////////// // Modified by Futur to hold Fishers from different length multipliers // // Market prices do not have a Gaussian probability density function // as many traders think. Their probability curve is not bell-shaped. // But trader can create a nearly Gaussian PDF for prices by normalizing // them or creating a normalized indicator such as the relative strength // index and applying the Fisher transform. Such a transformed output // creates the peak swings as relatively rare events. // Fisher transform formula is: y = 0.5 * ln ((1+x)/(1-x)) // The sharp turning points of these peak swings clearly and unambiguously // identify price reversals in a timely manner. //////////////////////////////////////////////////////////// //study(title="Fisher Transform Ribbons Indicator", shorttitle="FTR 1.0") Len = input(10, minval=1) mult1 = input(1, minval=1) mult2 = input(2, minval=1) mult3 = input(4, minval=1) mult4 = input(8, minval=1) fish(Length,timeMultiplier)=> xHL2 = hl2 xMaxH = highest(xHL2, Length*timeMultiplier) xMinL = lowest(xHL2,Length*timeMultiplier) nValue1=0.0 nFish=0.0 nValue1 := 0.33 * 2 * ((xHL2 - xMinL) / (xMaxH - xMinL) - 0.5) + 0.67 * nz(nValue1[1]) nValue2 = iff(nValue1 > .99, .999,iff(nValue1 < -.99, -.999, nValue1)) nFish := 0.5 * log((1 + nValue2) / (1 - nValue2)) + 0.5 * nz(nFish[1]) nFish Fisher1 = fish(Len,mult1) Fisher2 = fish(Len,mult2) Fisher4 = fish(Len,mult3) Fisher8 = fish(Len,mult4) //plot(nFish, color=green, title="Fisher") //plot(nz(nFish[1]), color=red, title="Trigger") plot(Fisher1,color=(Fisher1>nz(Fisher1[1])?lime:#ff0000),title="Fisher TF:1") plot(Fisher2,color=(Fisher2>nz(Fisher2[1])?green:red),title="Fisher TF:1", linewidth=2) plot(Fisher4,color=(Fisher4>nz(Fisher4[1])?#008000:#b60000),title="Fisher TF:1", linewidth=3) plot(Fisher8,color=(Fisher8>nz(Fisher8[1])?#004f00:maroon),title="Fisher TF:1", linewidth=3)