Laguerre Multi-Filter For ThinkOrSwim

Join useThinkScript to post your question to a community of 21,000+ developers and traders.

Convert Tradingview Laguerre Multi-Filter for ThinkorSwim.

https://www.tradingview.com/script/JwaPW9af-Laguerre-Multi-Filter-DW/

Ruby:
//@version=2
study(title="Laguerre Multi-Filter [DW]", shorttitle="LMF [DW]", overlay=true)
//by Donovan Wall

//This is an experimental study designed to identify underlying price activity using a series of Laguerre Filters.

//Two different modes are included within this script:
// -Ribbon Mode - A ribbon of 18 Laguerre Filters with separate Gamma values is calculated.
// -Band Mode - An average of the 18 filters generates the basis line. Then, Golden Mean ATR over the specified sampling period multiplied by 1 and 2 are added and subtracted to the basis line to generate the bands.

//Multi-Timeframe functionality is included. You can choose any timeframe that TradingView supports as the basis resolution for the script.

//Custom bar colors are included. Bar colors are based on the direction of any of the 18 filters, or the average filter's direction in Ribbon Mode. In Band Mode, the colors are based solely on the average filter's direction.

//-----------------------------------------------------------------------------------------------------------------------------------------------------------------
//Updates:
//I've refined the script structure to improve efficiency and reduce runtime.

//ATR is now eliminated within this script and has been replaced with Average Laguerre True Range, which is calculated by applying the average Laguerre filter to True Range. This eliminates the need to choose an arbitrary sampling period and delivers more effective results.

//-----------------------------------------------------------------------------------------------------------------------------------------------------------------
//Inputs
//-----------------------------------------------------------------------------------------------------------------------------------------------------------------
 
//Source
src = input(defval=hlc3, title="Source")

//Mode Selection
mode = input(defval=1, minval=1, maxval=2, title="Mode Selection (1 = Ribbon Mode, 2 = Band Mode)")

//Ribbon Based Bar Color
rbc = input(defval=19, minval=1, maxval=19, title="Ribbon Mode Bar Color (1-18 = Corresponding Filter Color, 19 = Average Filter Based Color)")

//Alternate Resolution
eares   = input(defval=false, title="Enable Alternate Resolution")
altres  = input(defval="D",   title="Alternate Resolution")

//Gamma Inputs
gamma1  = input(defval=0.1,  step=0.001, title="Gamma 1")
gamma2  = input(defval=0.15, step=0.001, title="Gamma 2")
gamma3  = input(defval=0.2,  step=0.001, title="Gamma 3")
gamma4  = input(defval=0.25, step=0.001, title="Gamma 4")
gamma5  = input(defval=0.3,  step=0.001, title="Gamma 5")
gamma6  = input(defval=0.35, step=0.001, title="Gamma 6")
gamma7  = input(defval=0.4,  step=0.001, title="Gamma 7")
gamma8  = input(defval=0.45, step=0.001, title="Gamma 8")
gamma9  = input(defval=0.5,  step=0.001, title="Gamma 9")
gamma10 = input(defval=0.55, step=0.001, title="Gamma 10")
gamma11 = input(defval=0.6,  step=0.001, title="Gamma 11")
gamma12 = input(defval=0.65, step=0.001, title="Gamma 12")
gamma13 = input(defval=0.7,  step=0.001, title="Gamma 13")
gamma14 = input(defval=0.75, step=0.001, title="Gamma 14")
gamma15 = input(defval=0.8,  step=0.001, title="Gamma 15")
gamma16 = input(defval=0.85, step=0.001, title="Gamma 16")
gamma17 = input(defval=0.9,  step=0.001, title="Gamma 17")
gamma18 = input(defval=0.95, step=0.001, title="Gamma 18")

//-----------------------------------------------------------------------------------------------------------------------------------------------------------------
//Definitions
//-----------------------------------------------------------------------------------------------------------------------------------------------------------------

//Laguerre Filter
laguerre(a, b) =>
    l0       = (1 - b)*a+b*nz(l0[1])
    l1       = -b*l0+nz(l0[1])+b*nz(l1[1])
    l2       = -b*l1+nz(l1[1])+b*nz(l2[1])
    l3       = -b*l2+nz(l2[1])+b*nz(l3[1])
    laguerre = (l0 + 2*l1 + 2*l2 + l3)/6

//Filter Values
lag1  = laguerre(src, gamma1)
lag2  = laguerre(src, gamma2)
lag3  = laguerre(src, gamma3)
lag4  = laguerre(src, gamma4)
lag5  = laguerre(src, gamma5)
lag6  = laguerre(src, gamma6)
lag7  = laguerre(src, gamma7)
lag8  = laguerre(src, gamma8)
lag9  = laguerre(src, gamma9)
lag10 = laguerre(src, gamma10)
lag11 = laguerre(src, gamma11)
lag12 = laguerre(src, gamma12)
lag13 = laguerre(src, gamma13)
lag14 = laguerre(src, gamma14)
lag15 = laguerre(src, gamma15)
lag16 = laguerre(src, gamma16)
lag17 = laguerre(src, gamma17)
lag18 = laguerre(src, gamma18)

//Multi-Resolution Filter Values
mlag1   = eares ? security(tickerid, altres, lag1) : lag1
mlag2   = eares ? security(tickerid, altres, lag2) : lag2
mlag3   = eares ? security(tickerid, altres, lag3) : lag3
mlag4   = eares ? security(tickerid, altres, lag4) : lag4
mlag5   = eares ? security(tickerid, altres, lag5) : lag5
mlag6   = eares ? security(tickerid, altres, lag6) : lag6
mlag7   = eares ? security(tickerid, altres, lag7) : lag7
mlag8   = eares ? security(tickerid, altres, lag8) : lag8
mlag9   = eares ? security(tickerid, altres, lag9) : lag9
mlag10  = eares ? security(tickerid, altres, lag10) : lag10
mlag11  = eares ? security(tickerid, altres, lag11) : lag11
mlag12  = eares ? security(tickerid, altres, lag12) : lag12
mlag13  = eares ? security(tickerid, altres, lag13) : lag13
mlag14  = eares ? security(tickerid, altres, lag14) : lag14
mlag15  = eares ? security(tickerid, altres, lag15) : lag15
mlag16  = eares ? security(tickerid, altres, lag16) : lag16
mlag17  = eares ? security(tickerid, altres, lag17) : lag17
mlag18  = eares ? security(tickerid, altres, lag18) : lag18

//Multi-Resolution Previous Filter Values
mlag1prev   = eares ? security(tickerid, altres, lag1[1]) : lag1[1]
mlag2prev   = eares ? security(tickerid, altres, lag2[1]) : lag2[1]
mlag3prev   = eares ? security(tickerid, altres, lag3[1]) : lag3[1]
mlag4prev   = eares ? security(tickerid, altres, lag4[1]) : lag4[1]
mlag5prev   = eares ? security(tickerid, altres, lag5[1]) : lag5[1]
mlag6prev   = eares ? security(tickerid, altres, lag6[1]) : lag6[1]
mlag7prev   = eares ? security(tickerid, altres, lag7[1]) : lag7[1]
mlag8prev   = eares ? security(tickerid, altres, lag8[1]) : lag8[1]
mlag9prev   = eares ? security(tickerid, altres, lag9[1]) : lag9[1]
mlag10prev  = eares ? security(tickerid, altres, lag10[1]) : lag10[1]
mlag11prev  = eares ? security(tickerid, altres, lag11[1]) : lag11[1]
mlag12prev  = eares ? security(tickerid, altres, lag12[1]) : lag12[1]
mlag13prev  = eares ? security(tickerid, altres, lag13[1]) : lag13[1]
mlag14prev  = eares ? security(tickerid, altres, lag14[1]) : lag14[1]
mlag15prev  = eares ? security(tickerid, altres, lag15[1]) : lag15[1]
mlag16prev  = eares ? security(tickerid, altres, lag16[1]) : lag16[1]
mlag17prev  = eares ? security(tickerid, altres, lag17[1]) : lag17[1]
mlag18prev  = eares ? security(tickerid, altres, lag18[1]) : lag18[1]

//Multi-Resolution Average Laguerre Filter
amlag     = (mlag1 + mlag2 + mlag3 + mlag4 + mlag5 + mlag6 + mlag7 + mlag8 + mlag9 + mlag10 + mlag11 + mlag12 + mlag13 + mlag14 + mlag15 + mlag16 + mlag17 + mlag18)/18
amlagprev = (mlag1prev + mlag2prev + mlag3prev + mlag4prev + mlag5prev + mlag6prev + mlag7prev + mlag8prev + mlag9prev + mlag10prev + mlag11prev + mlag12prev + mlag13prev + mlag14prev + mlag15prev + mlag16prev + mlag17prev + mlag18prev)/18

//Average Laguerre True Range
altr      = (laguerre(tr, gamma1) + laguerre(tr, gamma2) + laguerre(tr, gamma3) + laguerre(tr, gamma4) + laguerre(tr, gamma5) + laguerre(tr, gamma6) + laguerre(tr, gamma7) + laguerre(tr, gamma8) + laguerre(tr, gamma9) + laguerre(tr, gamma10) + laguerre(tr, gamma11) + laguerre(tr, gamma12) + laguerre(tr, gamma13) + laguerre(tr, gamma14) + laguerre(tr, gamma15) + laguerre(tr, gamma16) + laguerre(tr, gamma17) + laguerre(tr, gamma18))/18
maltr     = eares ? security(tickerid, altres, altr) : altr

//Bands
hb1 = amlag + maltr*1.618
hb2 = amlag + 2*maltr*1.618
lb1 = amlag - maltr*1.618
lb2 = amlag - 2*maltr*1.618

//Colors
rcolor1   = mlag1 > mlag1prev ? lime : mlag1 < mlag1prev ? red : orange
rcolor2   = mlag2 > mlag2prev ? lime : mlag2 < mlag2prev ? red : orange
rcolor3   = mlag3 > mlag3prev ? lime : mlag3 < mlag3prev ? red : orange
rcolor4   = mlag4 > mlag4prev ? lime : mlag4 < mlag4prev ? red : orange
rcolor5   = mlag5 > mlag5prev ? lime : mlag5 < mlag5prev ? red : orange
rcolor6   = mlag6 > mlag6prev ? lime : mlag6 < mlag6prev ? red : orange
rcolor7   = mlag7 > mlag7prev ? lime : mlag7 < mlag7prev ? red : orange
rcolor8   = mlag8 > mlag8prev ? lime : mlag8 < mlag8prev ? red : orange
rcolor9   = mlag9 > mlag9prev ? lime : mlag9 < mlag9prev ? red : orange
rcolor10  = mlag10 > mlag10prev ? lime : mlag10 < mlag10prev ? red : orange
rcolor11  = mlag11 > mlag11prev ? lime : mlag11 < mlag11prev ? red : orange
rcolor12  = mlag12 > mlag12prev ? lime : mlag12 < mlag12prev ? red : orange
rcolor13  = mlag13 > mlag13prev ? lime : mlag13 < mlag13prev ? red : orange
rcolor14  = mlag14 > mlag14prev ? lime : mlag14 < mlag14prev ? red : orange
rcolor15  = mlag15 > mlag15prev ? lime : mlag15 < mlag15prev ? red : orange
rcolor16  = mlag16 > mlag16prev ? lime : mlag16 < mlag16prev ? red : orange
rcolor17  = mlag17 > mlag17prev ? lime : mlag17 < mlag17prev ? red : orange
rcolor18  = mlag18 > mlag18prev ? lime : mlag18 < mlag18prev ? red : orange
bcolor    = amlag > amlagprev ? lime : amlag < amlagprev ? red : orange
rbarcolor = rbc==1 ? rcolor1 : rbc==2 ? rcolor2 : rbc==3 ? rcolor3 : rbc==4 ? rcolor4 : rbc==5 ? rcolor5 : rbc==6 ? rcolor6 : rbc==7 ? rcolor7 : rbc==8 ? rcolor8 : rbc==9 ? rcolor9 : rbc==10 ? rcolor10 : rbc==11 ? rcolor11 : rbc==12 ? rcolor12 : rbc==13 ? rcolor13 : rbc==14 ? rcolor14 : rbc==15 ? rcolor15 : rbc==16 ? rcolor16 : rbc==17 ? rcolor17 : rbc==18 ? rcolor18 : bcolor
barcolor  = mode==1 ? rbarcolor : bcolor

//-----------------------------------------------------------------------------------------------------------------------------------------------------------------
//Plots
//-----------------------------------------------------------------------------------------------------------------------------------------------------------------

//Ribbon Plots
plot(mode==1 ? mlag18 : na, color=rcolor18, linewidth=1, title="Laguerre Filter 18")
plot(mode==1 ? mlag17 : na, color=rcolor17, linewidth=1, title="Laguerre Filter 17")
plot(mode==1 ? mlag16 : na, color=rcolor16, linewidth=1, title="Laguerre Filter 16")
plot(mode==1 ? mlag15 : na, color=rcolor15, linewidth=1, title="Laguerre Filter 15")
plot(mode==1 ? mlag14 : na, color=rcolor14, linewidth=1, title="Laguerre Filter 14")
plot(mode==1 ? mlag13 : na, color=rcolor13, linewidth=1, title="Laguerre Filter 13")
plot(mode==1 ? mlag12 : na, color=rcolor12, linewidth=1, title="Laguerre Filter 12")
plot(mode==1 ? mlag11 : na, color=rcolor11, linewidth=1, title="Laguerre Filter 11")
plot(mode==1 ? mlag10 : na, color=rcolor10, linewidth=1, title="Laguerre Filter 10")
plot(mode==1 ? mlag9 : na,  color=rcolor9,  linewidth=1, title="Laguerre Filter 9")
plot(mode==1 ? mlag8 : na,  color=rcolor8,  linewidth=1, title="Laguerre Filter 8")
plot(mode==1 ? mlag7 : na,  color=rcolor7,  linewidth=1, title="Laguerre Filter 7")
plot(mode==1 ? mlag6 : na,  color=rcolor6,  linewidth=1, title="Laguerre Filter 6")
plot(mode==1 ? mlag5 : na,  color=rcolor5,  linewidth=1, title="Laguerre Filter 5")
plot(mode==1 ? mlag4 : na,  color=rcolor4,  linewidth=1, title="Laguerre Filter 4")
plot(mode==1 ? mlag3 : na,  color=rcolor3,  linewidth=1, title="Laguerre Filter 3")
plot(mode==1 ? mlag2 : na,  color=rcolor2,  linewidth=1, title="Laguerre Filter 2")
plot(mode==1 ? mlag1 : na,  color=rcolor1,  linewidth=1, title="Laguerre Filter 1")

//Band Plots
hplot2 = plot(mode==2 ? hb2 : na,   color=bcolor, linewidth=1, title="High Band 2")
hplot1 = plot(mode==2 ? hb1 : na,   color=bcolor, linewidth=1, title="High Band 1")
alplot = plot(mode==2 ? amlag : na, color=bcolor, linewidth=2, title="Average Laguerre Filter")
lplot1 = plot(mode==2 ? lb1 : na,   color=bcolor, linewidth=1, title="Low Band 1")
lplot2 = plot(mode==2 ? lb2 : na,   color=bcolor, linewidth=1, title="Low Band 2")

//Band Fills
fill(hplot1, hplot2, color=bcolor, title="High Band Fill")
fill(lplot1, lplot2, color=bcolor, title="Low Band Fill")

//Bar Color
barcolor(barcolor)
check the below

CSS:
#study(title="Laguerre Multi-Filter [DW]", shorttitle="LMF [DW]", overlay=true)
#//by Donovan Wall
# converted and by Sam4Cok@Samer800 - 02/2023  - request from www.useThinkScript.com memeber

#//Source
input Source = hlc3;    # "Source"
input ColorBar = yes;
input PlotMode = { default Ribbon, Band, None};    # "Mode Selection
input rbc = 19;    # "Ribbon Mode Bar Color (1-18 = Corresponding Filter Color, 19 = Average Filter Based Color)"
input UseAlternateResolution = no;    # "Enable Alternate Resolution"
input AlternateResolution  = AggregationPeriod.DAY;    # "Alternate Resolution"

DefineGlobalColor("0"  , Color.GRAY);
DefineGlobalColor("gr"  , CreateColor(40,88,167));
DefineGlobalColor("re"  , CreateColor(155,19,19));

def na = Double.NaN;
def ribbon = PlotMode==PlotMode.Ribbon;
def band   = PlotMode==PlotMode.Band;
def src;
def src1;
def htf;
def ltf;
def ctf;
if UseAlternateResolution {
    src = hlc3(Period = AlternateResolution);
    src1 = hlc3(Period = AlternateResolution)[1];
    htf = high(Period = AlternateResolution);
    ltf = low(Period = AlternateResolution);
    ctf = close(Period = AlternateResolution);
} else {
    src = Source;
    src1 = src[1];
    htf = high;
    ltf = low;
    ctf = close;
}
#//Gamma Inputs
input gamma1  = 0.1; #,  step=0.001, title="Gamma 1")
input gamma2  = 0.15;#, step=0.001, title="Gamma 2")
input gamma3  = 0.2;#,  step=0.001, title="Gamma 3")
input gamma4  = 0.25;#, step=0.001, title="Gamma 4")
input gamma5  = 0.3;#,  step=0.001, title="Gamma 5")
input gamma6  = 0.35;#, step=0.001, title="Gamma 6")
input gamma7  = 0.4;#,  step=0.001, title="Gamma 7")
input gamma8  = 0.45;#, step=0.001, title="Gamma 8")
input gamma9  = 0.5;#,  step=0.001, title="Gamma 9")
input gamma10 = 0.55;#, step=0.001, title="Gamma 10")
input gamma11 = 0.6;#,  step=0.001, title="Gamma 11")
input gamma12 = 0.65;#, step=0.001, title="Gamma 12")
input gamma13 = 0.7;#,  step=0.001, title="Gamma 13")
input gamma14 = 0.75;#, step=0.001, title="Gamma 14")
input gamma15 = 0.8;#,  step=0.001, title="Gamma 15")
input gamma16 = 0.85;#, step=0.001, title="Gamma 16")
input gamma17 = 0.9;#,  step=0.001, title="Gamma 17")
input gamma18 = 0.95;#, step=0.001, title="Gamma 18")

#//Definitions
#//Laguerre Filter
#laguerre(a, b) =>
script laguerre {
    input a = hlc3;
    input b = 0.1;
    def l0       = CompoundValue(1, (1 - b) * a + b * l0[1] , a);
    def l1       = CompoundValue(1, -b * l0 + l0[1] + b * l1[1] , l0);
    def l2       = CompoundValue(1, -b * l1 + l1[1] + b * l2[1] , l1);
    def l3       = CompoundValue(1, -b * l2 + l2[1] + b * l3[1] , l2);
    def laguerre = (l0 + 2 * l1 + 2 * l2 + l3) / 6;
    plot return = laguerre;
}

#//Filter Values
def lag1  = laguerre(src, gamma1);
def lag2  = laguerre(src, gamma2);
def lag3  = laguerre(src, gamma3);
def lag4  = laguerre(src, gamma4);
def lag5  = laguerre(src, gamma5);
def lag6  = laguerre(src, gamma6);
def lag7  = laguerre(src, gamma7);
def lag8  = laguerre(src, gamma8);
def lag9  = laguerre(src, gamma9);
def lag10 = laguerre(src, gamma10);
def lag11 = laguerre(src, gamma11);
def lag12 = laguerre(src, gamma12);
def lag13 = laguerre(src, gamma13);
def lag14 = laguerre(src, gamma14);
def lag15 = laguerre(src, gamma15);
def lag16 = laguerre(src, gamma16);
def lag17 = laguerre(src, gamma17);
def lag18 = laguerre(src, gamma18);
#--- Prev
def plag1  = laguerre(src1, gamma1);
def plag2  = laguerre(src1, gamma2);
def plag3  = laguerre(src1, gamma3);
def plag4  = laguerre(src1, gamma4);
def plag5  = laguerre(src1, gamma5);
def plag6  = laguerre(src1, gamma6);
def plag7  = laguerre(src1, gamma7);
def plag8  = laguerre(src1, gamma8);
def plag9  = laguerre(src1, gamma9);
def plag10 = laguerre(src1, gamma10);
def plag11 = laguerre(src1, gamma11);
def plag12 = laguerre(src1, gamma12);
def plag13 = laguerre(src1, gamma13);
def plag14 = laguerre(src1, gamma14);
def plag15 = laguerre(src1, gamma15);
def plag16 = laguerre(src1, gamma16);
def plag17 = laguerre(src1, gamma17);
def plag18 = laguerre(src1, gamma18);

#//Multi-Resolution Average Laguerre Filter
def amlag     = (lag1 + lag2 + lag3 + lag4 + lag5 + lag6 + lag7 + lag8 + lag9 + lag10 + lag11 + lag12 + lag13 + lag14 + lag15 + lag16 + lag17 + lag18) / 18;
def amlagprev = (plag1 + plag2 + plag3 + plag4 + plag5 + plag6 + plag7 + plag8 + plag9 + plag10 + plag11 + plag12 + plag13 + plag14 + plag15 + plag16 + plag17 + plag18) / 18;

def tr = TrueRange(htf, ctf, ltf);
def maltr = (laguerre(tr, gamma1) + laguerre(tr, gamma2) + laguerre(tr, gamma3) + laguerre(tr, gamma4) + laguerre(tr, gamma5) + laguerre(tr, gamma6) + laguerre(tr, gamma7) + laguerre(tr, gamma8) + laguerre(tr, gamma9) + laguerre(tr, gamma10) + laguerre(tr, gamma11) + laguerre(tr, gamma12) + laguerre(tr, gamma13) + laguerre(tr, gamma14) + laguerre(tr, gamma15) + laguerre(tr, gamma16) + laguerre(tr, gamma17) + laguerre(tr, gamma18)) / 18;

#//Bands
def hb1 = amlag + maltr * 1.618;
def hb2 = amlag + 2 * maltr * 1.618;
def lb1 = amlag - maltr * 1.618;
def lb2 = amlag - 2 * maltr * 1.618;

#//Colors
def rcolor1   = if lag1 > plag1 then 1 else if lag1 < plag1 then -1 else 0;
def rcolor2   = if lag2 > plag2 then 1 else if lag2 < plag2 then -1 else 0;
def rcolor3   = if lag3 > plag3 then 1 else if lag3 < plag3 then -1 else 0;
def rcolor4   = if lag4 > plag4 then 1 else if lag4 < plag4 then -1 else 0;
def rcolor5   = if lag5 > plag5 then 1 else if lag5 < plag5 then -1 else 0;
def rcolor6   = if lag6 > plag6 then 1 else if lag6 < plag6 then -1 else 0;
def rcolor7   = if lag7 > plag7 then 1 else if lag7 < plag7 then -1 else 0;
def rcolor8   = if lag8 > plag8 then 1 else if lag8 < plag8 then -1 else 0;
def rcolor9   = if lag9 > plag9 then 1 else if lag9 < plag9 then -1 else 0;
def rcolor10  = if lag10 > plag10 then 1 else if lag10 < plag10 then -1 else 0;
def rcolor11  = if lag11 > plag11 then 1 else if lag11 < plag11 then -1 else 0;
def rcolor12  = if lag12 > plag12 then 1 else if lag12 < plag12 then -1 else 0;
def rcolor13  = if lag13 > plag13 then 1 else if lag13 < plag13 then -1 else 0;
def rcolor14  = if lag14 > plag14 then 1 else if lag14 < plag14 then -1 else 0;
def rcolor15  = if lag15 > plag15 then 1 else if lag15 < plag15 then -1 else 0;
def rcolor16  = if lag16 > plag16 then 1 else if lag16 < plag16 then -1 else 0;
def rcolor17  = if lag17 > plag17 then 1 else if lag17 < plag17 then -1 else 0;
def rcolor18  = if lag18 > plag18 then 1 else if lag18 < plag18 then -1 else 0;
def bcolor    = if amlag > amlagprev then 1 else if amlag < amlagprev then -1 else 0;

def rbarcolor = if rbc == 1 then rcolor1 else if rbc == 2 then rcolor2 else if rbc == 3 then rcolor3 else if rbc == 4 then rcolor4 else if rbc == 5 then rcolor5 else if rbc == 6 then rcolor6 else if rbc == 7 then rcolor7 else if rbc == 8 then rcolor8 else if rbc == 9 then  rcolor9 else if rbc == 10 then rcolor10 else if rbc == 11 then rcolor11 else if rbc == 12 then rcolor12 else if rbc == 13 then rcolor13 else if rbc == 14 then rcolor14 else if rbc == 15 then rcolor15 else if rbc == 16 then rcolor16 else if rbc == 17 then rcolor17 else if rbc == 18 then rcolor18 else bcolor;

def barcolor  = if ribbon then rbarcolor else if band then bcolor else rbarcolor;

plot L1 = if ribbon then lag1 else na;
plot L2 = if ribbon then lag2 else na;
plot L3 = if ribbon then lag3 else na;
plot L4 = if ribbon then lag4 else na;
plot L5 = if ribbon then lag5 else na;
plot L6 = if ribbon then lag6 else na;
plot L7 = if ribbon then lag7 else na;
plot L8 = if ribbon then lag8 else na;
plot L9 = if ribbon then lag9 else na;
plot L10 = if ribbon then lag10 else na;
plot L11 = if ribbon then lag11 else na;
plot L12 = if ribbon then lag12 else na;
plot L13 = if ribbon then lag13 else na;
plot L14 = if ribbon then lag14 else na;
plot L15 = if ribbon then lag15 else na;
plot L16 = if ribbon then lag16 else na;
plot L17 = if ribbon then lag17 else na;
plot L18 = if ribbon then lag18 else na;
L1.AssignValueColor(if rcolor1>0 then GlobalColor("gr") else if rcolor1<0 then GlobalColor("re") else GlobalColor("0"));
L2.AssignValueColor(if rcolor2>0 then GlobalColor("gr") else if rcolor2<0 then GlobalColor("re") else GlobalColor("0"));
L3.AssignValueColor(if rcolor3>0 then GlobalColor("gr") else if rcolor3<0 then GlobalColor("re") else GlobalColor("0"));
L4.AssignValueColor(if rcolor4>0 then GlobalColor("gr") else if rcolor4<0 then GlobalColor("re") else GlobalColor("0"));
L5.AssignValueColor(if rcolor5>0 then GlobalColor("gr") else if rcolor5<0 then GlobalColor("re") else GlobalColor("0"));
L6.AssignValueColor(if rcolor6>0 then GlobalColor("gr") else if rcolor6<0 then GlobalColor("re") else GlobalColor("0"));
L7.AssignValueColor(if rcolor7>0 then GlobalColor("gr") else if rcolor7<0 then GlobalColor("re") else GlobalColor("0"));
L8.AssignValueColor(if rcolor8>0 then GlobalColor("gr") else if rcolor8<0 then GlobalColor("re") else GlobalColor("0"));
L9.AssignValueColor(if rcolor9>0 then GlobalColor("gr") else if rcolor9<0 then GlobalColor("re") else GlobalColor("0"));
L10.AssignValueColor(if rcolor10>0 then GlobalColor("gr") else if rcolor10<0 then GlobalColor("re") else GlobalColor("0"));
L11.AssignValueColor(if rcolor11>0 then GlobalColor("gr") else if rcolor11<0 then GlobalColor("re") else GlobalColor("0"));
L12.AssignValueColor(if rcolor12>0 then GlobalColor("gr") else if rcolor12<0 then GlobalColor("re") else GlobalColor("0"));
L13.AssignValueColor(if rcolor13>0 then GlobalColor("gr") else if rcolor13<0 then GlobalColor("re") else GlobalColor("0"));
L14.AssignValueColor(if rcolor14>0 then GlobalColor("gr") else if rcolor14<0 then GlobalColor("re") else GlobalColor("0"));
L15.AssignValueColor(if rcolor15>0 then GlobalColor("gr") else if rcolor15<0 then GlobalColor("re") else GlobalColor("0"));
L16.AssignValueColor(if rcolor16>0 then GlobalColor("gr") else if rcolor16<0 then GlobalColor("re") else GlobalColor("0"));
L17.AssignValueColor(if rcolor17>0 then GlobalColor("gr") else if rcolor17<0 then GlobalColor("re") else GlobalColor("0"));
L18.AssignValueColor(if rcolor18>0 then GlobalColor("gr") else if rcolor18<0 then GlobalColor("re") else GlobalColor("0"));

#//Band Plots
plot hplot2 = if band then hb2 else na;    # "High Band 2")
plot hplot1 = if band then hb1 else na;    # "High Band 1")
plot alplot = if band then amlag else na;  # "Average Laguerre Filter")
plot lplot1 = if band then lb1 else na;    # "Low Band 1")
plot lplot2 = if band then lb2 else na;    # "Low Band 2")

hplot2.AssignValueColor(if bcolor>0 then GlobalColor("gr") else Color.DARK_RED);
hplot1.AssignValueColor(if bcolor>0 then GlobalColor("gr") else Color.DARK_RED);
alplot.AssignValueColor(if bcolor>0 then GlobalColor("gr") else Color.DARK_RED);
lplot1.AssignValueColor(if bcolor>0 then GlobalColor("gr") else Color.DARK_RED);
lplot2.AssignValueColor(if bcolor>0 then GlobalColor("gr") else Color.DARK_RED);

#//Band Fills
AddCloud(if barcolor>0 then hplot2 else hplot1,if barcolor>0 then hplot1 else hplot2, GlobalColor("gr"),Color.DARK_RED);
AddCloud(if barcolor<0 then lplot1 else lplot2,if barcolor<0 then lplot2 else lplot1, Color.DARK_RED, GlobalColor("gr"));

#-- BarColor
AssignPriceColor(if !ColorBar then Color.CURRENT else
                 if barcolor>0 then if Source>hb1 then Color.GREEN else Color.DARK_GREEN else
                 if barcolor<0 then if Source<lb1 then Color.RED else Color.DARK_RED else Color.GRAY);


#--- END CODE
 

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
267 Online
Create Post

Similar threads

Similar threads

The Market Trading Game Changer

Join 2,500+ subscribers inside the useThinkScript VIP Membership Club
  • Exclusive indicators
  • Proven strategies & setups
  • Private Discord community
  • ‘Buy The Dip’ signal alerts
  • Exclusive members-only content
  • Add-ons and resources
  • 1 full year of unlimited support

Frequently Asked Questions

What is useThinkScript?

useThinkScript is the #1 community of stock market investors using indicators and other tools to power their trading strategies. Traders of all skill levels use our forums to learn about scripting and indicators, help each other, and discover new ways to gain an edge in the markets.

How do I get started?

We get it. Our forum can be intimidating, if not overwhelming. With thousands of topics, tens of thousands of posts, our community has created an incredibly deep knowledge base for stock traders. No one can ever exhaust every resource provided on our site.

If you are new, or just looking for guidance, here are some helpful links to get you started.

What are the benefits of VIP Membership?
VIP members get exclusive access to these proven and tested premium indicators: Buy the Dip, Advanced Market Moves 2.0, Take Profit, and Volatility Trading Range. In addition, VIP members get access to over 50 VIP-only custom indicators, add-ons, and strategies, private VIP-only forums, private Discord channel to discuss trades and strategies in real-time, customer support, trade alerts, and much more. Learn all about VIP membership here.
How can I access the premium indicators?
To access the premium indicators, which are plug and play ready, sign up for VIP membership here.
Back
Top