Page 166 of 193

Re: Bollinger Band type indicators for MT4

Posted: Wed May 24, 2023 3:34 am
by TE81950
mrtools wrote: Thu Dec 10, 2020 5:37 am Found the bars were probably repainting, try this one. The projection part will repaint sometimes.
Thanks for sharing this indicator just have one question

Does the candle colors reprint when it's in the process of Crossing the channel

Re: Bollinger Bands type indicators for MT4

Posted: Fri Jun 23, 2023 4:39 am
by chris006
Hi mrtools,

Please consider adding additional Bollinger Bands to a BB Squeeze of your selection, like the below indi SQZMOM_LB on Trading View.

Code: Select all

//
// @author LazyBear 
// List of all my indicators: https://www.tradingview.com/v/4IneGo8h/
//
study(shorttitle = "SQZMOM_LB", title="Squeeze Momentum Indicator 20 40 60 80", overlay=false)

length1 = input(20, title="BB Length")
length2 = input(40, title="BB Length")
length3 = input(60, title="BB Length")
length4 = input(80, title="BB Length")
mult = input(2.0,title="BB MultFactor")
lengthKC1=input(20, title="KC Length")
lengthKC2=input(40, title="KC Length")
lengthKC3=input(60, title="KC Length")
lengthKC4=input(80, title="KC Length")
multKC1 = input(1.5, title="KC MultFactor")
multKC2 = input(1.5, title="KC MultFactor")
multKC3 = input(1.5, title="KC MultFactor")
multKC4 = input(1.5, title="KC MultFactor")

useTrueRange = input(true, title="Use TrueRange (KC)", type=bool)

// Calculate BB
source = close
basis = sma(source, length1)
dev = multKC1 * stdev(source, length1)
upperBB = basis + dev
lowerBB = basis - dev

// Calculate KC
ma = sma(source, lengthKC1)
range = useTrueRange ? tr : (high - low)
rangema = sma(range, lengthKC1)
upperKC = ma + rangema * multKC1
lowerKC = ma - rangema * multKC1

sqzOn  = (lowerBB > lowerKC) and (upperBB < upperKC)
sqzOff = (lowerBB < lowerKC) and (upperBB > upperKC)
noSqz  = (sqzOn == false) and (sqzOff == false)

val = linreg(source  -  avg(avg(highest(high, lengthKC1), lowest(low, lengthKC1)),sma(close,lengthKC1)), 
            lengthKC1,0)

bcolor = iff( val > 0, 
            iff( val > nz(val[1]), lime, green),
            iff( val < nz(val[1]), red, maroon))
scolor = noSqz ? blue : sqzOn ? black : gray 
plot(val, color=bcolor, style=histogram, linewidth=4, transp=0)
plot(0, color=scolor, style=cross, linewidth=2, transp=0)


// Calculate BB
basis2 = sma(source, length2)
dev2 = multKC2 * stdev(source, length2)
upperBB2 = basis2 + dev2
lowerBB2 = basis2 - dev2

// Calculate KC
ma2 = sma(source, lengthKC2)
range2 = useTrueRange ? tr : (high - low)
rangema2 = sma(range2, lengthKC2)
upperKC2 = ma2 + rangema2 * multKC2
lowerKC2 = ma2 - rangema2 * multKC2

sqzOn2  = (lowerBB2 > lowerKC2) and (upperBB2 < upperKC2)
sqzOff2 = (lowerBB2 < lowerKC2) and (upperBB2 > upperKC2)
noSqz2  = (sqzOn2 == false) and (sqzOff2 == false)

val2 = linreg(source  -  avg(avg(highest(high, lengthKC2), lowest(low, lengthKC2)),sma(close,lengthKC2)), 
            lengthKC2,0)

bcolor2 = iff( val2 > 0, 
            iff( val2 > nz(val2[1]), lime, green),
            iff( val2 < nz(val2[1]), red, maroon))
scolor2 = noSqz2 ? blue : sqzOn2 ? black : gray 
plot(val2*1.2, color=bcolor2, style=line, linewidth=2, transp=40)
//plot(0, color=scolor2, style=cross, linewidth=2, transp=40)

// Calculate BB
basis3 = sma(source, length3)
dev3 = multKC3 * stdev(source, length3)
upperBB3 = basis3 + dev3
lowerBB3 = basis3 - dev3

// Calculate KC
ma3 = sma(source, lengthKC3)
range3 = useTrueRange ? tr : (high - low)
rangema3 = sma(range3, lengthKC3)
upperKC3 = ma3 + rangema3 * multKC3
lowerKC3 = ma3 - rangema3 * multKC3

sqzOn3  = (lowerBB3 > lowerKC3) and (upperBB3 < upperKC3)
sqzOff3 = (lowerBB3 < lowerKC3) and (upperBB3 > upperKC3)
noSqz3  = (sqzOn3 == false) and (sqzOff3 == false)

val3 = linreg(source  -  avg(avg(highest(high, lengthKC3), lowest(low, lengthKC3)),sma(close,lengthKC3)), 
            lengthKC3,0)

bcolor3 = iff( val3 > 0, 
            iff( val3 > nz(val3[1]), lime, green),
            iff( val3 < nz(val3[1]), red, maroon))
scolor3 = noSqz3 ? blue : sqzOn3 ? black : gray 
plot(val3*1.4, color=bcolor3, style=line, linewidth=4, transp=40)
//plot(0, color=scolor3, style=cross, linewidth=3, transp=40)


// Calculate BB
basis4 = sma(source, length4)
dev4 = multKC4 * stdev(source, length4)
upperBB4 = basis4 + dev4
lowerBB4 = basis4 - dev4

// Calculate KC
ma4 = sma(source, lengthKC4)
range4 = useTrueRange ? tr : (high - low)
rangema4 = sma(range4, lengthKC4)
upperKC4 = ma4 + rangema4 * multKC4
lowerKC4 = ma4 - rangema4 * multKC4

sqzOn4  = (lowerBB4 > lowerKC4) and (upperBB4 < upperKC4)
sqzOff4 = (lowerBB4 < lowerKC4) and (upperBB4 > upperKC4)
noSqz4  = (sqzOn4 == false) and (sqzOff4 == false)

val4 = linreg(source  -  avg(avg(highest(high, lengthKC4), lowest(low, lengthKC4)),sma(close,lengthKC4)), 
            lengthKC4,0)

bcolor4 = iff( val4 > 0, 
            iff( val4 > nz(val4[1]), lime, green),
            iff( val4 < nz(val4[1]), red, maroon))
scolor4 = noSqz4 ? blue : sqzOn4 ? black : gray 
plot(val4*1.6, color=bcolor4, style=line, linewidth=8, transp=40)
//plot(0, color=scolor4, style=cross, linewidth=4, transp=40)


Re: Bollinger Bands type indicators for MT4

Posted: Fri Jun 23, 2023 5:53 am
by mrtools
chris006 wrote: Fri Jun 23, 2023 4:39 am Hi mrtools,

Please consider adding additional Bollinger Bands to a BB Squeeze of your selection, like the below indi SQZMOM_LB on Trading View.

Code: Select all

//
// @author LazyBear 
// List of all my indicators: https://www.tradingview.com/v/4IneGo8h/
//
study(shorttitle = "SQZMOM_LB", title="Squeeze Momentum Indicator 20 40 60 80", overlay=false)

length1 = input(20, title="BB Length")
length2 = input(40, title="BB Length")
length3 = input(60, title="BB Length")
length4 = input(80, title="BB Length")
mult = input(2.0,title="BB MultFactor")
lengthKC1=input(20, title="KC Length")
lengthKC2=input(40, title="KC Length")
lengthKC3=input(60, title="KC Length")
lengthKC4=input(80, title="KC Length")
multKC1 = input(1.5, title="KC MultFactor")
multKC2 = input(1.5, title="KC MultFactor")
multKC3 = input(1.5, title="KC MultFactor")
multKC4 = input(1.5, title="KC MultFactor")

useTrueRange = input(true, title="Use TrueRange (KC)", type=bool)

// Calculate BB
source = close
basis = sma(source, length1)
dev = multKC1 * stdev(source, length1)
upperBB = basis + dev
lowerBB = basis - dev

// Calculate KC
ma = sma(source, lengthKC1)
range = useTrueRange ? tr : (high - low)
rangema = sma(range, lengthKC1)
upperKC = ma + rangema * multKC1
lowerKC = ma - rangema * multKC1

sqzOn  = (lowerBB > lowerKC) and (upperBB < upperKC)
sqzOff = (lowerBB < lowerKC) and (upperBB > upperKC)
noSqz  = (sqzOn == false) and (sqzOff == false)

val = linreg(source  -  avg(avg(highest(high, lengthKC1), lowest(low, lengthKC1)),sma(close,lengthKC1)), 
            lengthKC1,0)

bcolor = iff( val > 0, 
            iff( val > nz(val[1]), lime, green),
            iff( val < nz(val[1]), red, maroon))
scolor = noSqz ? blue : sqzOn ? black : gray 
plot(val, color=bcolor, style=histogram, linewidth=4, transp=0)
plot(0, color=scolor, style=cross, linewidth=2, transp=0)


// Calculate BB
basis2 = sma(source, length2)
dev2 = multKC2 * stdev(source, length2)
upperBB2 = basis2 + dev2
lowerBB2 = basis2 - dev2

// Calculate KC
ma2 = sma(source, lengthKC2)
range2 = useTrueRange ? tr : (high - low)
rangema2 = sma(range2, lengthKC2)
upperKC2 = ma2 + rangema2 * multKC2
lowerKC2 = ma2 - rangema2 * multKC2

sqzOn2  = (lowerBB2 > lowerKC2) and (upperBB2 < upperKC2)
sqzOff2 = (lowerBB2 < lowerKC2) and (upperBB2 > upperKC2)
noSqz2  = (sqzOn2 == false) and (sqzOff2 == false)

val2 = linreg(source  -  avg(avg(highest(high, lengthKC2), lowest(low, lengthKC2)),sma(close,lengthKC2)), 
            lengthKC2,0)

bcolor2 = iff( val2 > 0, 
            iff( val2 > nz(val2[1]), lime, green),
            iff( val2 < nz(val2[1]), red, maroon))
scolor2 = noSqz2 ? blue : sqzOn2 ? black : gray 
plot(val2*1.2, color=bcolor2, style=line, linewidth=2, transp=40)
//plot(0, color=scolor2, style=cross, linewidth=2, transp=40)

// Calculate BB
basis3 = sma(source, length3)
dev3 = multKC3 * stdev(source, length3)
upperBB3 = basis3 + dev3
lowerBB3 = basis3 - dev3

// Calculate KC
ma3 = sma(source, lengthKC3)
range3 = useTrueRange ? tr : (high - low)
rangema3 = sma(range3, lengthKC3)
upperKC3 = ma3 + rangema3 * multKC3
lowerKC3 = ma3 - rangema3 * multKC3

sqzOn3  = (lowerBB3 > lowerKC3) and (upperBB3 < upperKC3)
sqzOff3 = (lowerBB3 < lowerKC3) and (upperBB3 > upperKC3)
noSqz3  = (sqzOn3 == false) and (sqzOff3 == false)

val3 = linreg(source  -  avg(avg(highest(high, lengthKC3), lowest(low, lengthKC3)),sma(close,lengthKC3)), 
            lengthKC3,0)

bcolor3 = iff( val3 > 0, 
            iff( val3 > nz(val3[1]), lime, green),
            iff( val3 < nz(val3[1]), red, maroon))
scolor3 = noSqz3 ? blue : sqzOn3 ? black : gray 
plot(val3*1.4, color=bcolor3, style=line, linewidth=4, transp=40)
//plot(0, color=scolor3, style=cross, linewidth=3, transp=40)


// Calculate BB
basis4 = sma(source, length4)
dev4 = multKC4 * stdev(source, length4)
upperBB4 = basis4 + dev4
lowerBB4 = basis4 - dev4

// Calculate KC
ma4 = sma(source, lengthKC4)
range4 = useTrueRange ? tr : (high - low)
rangema4 = sma(range4, lengthKC4)
upperKC4 = ma4 + rangema4 * multKC4
lowerKC4 = ma4 - rangema4 * multKC4

sqzOn4  = (lowerBB4 > lowerKC4) and (upperBB4 < upperKC4)
sqzOff4 = (lowerBB4 < lowerKC4) and (upperBB4 > upperKC4)
noSqz4  = (sqzOn4 == false) and (sqzOff4 == false)

val4 = linreg(source  -  avg(avg(highest(high, lengthKC4), lowest(low, lengthKC4)),sma(close,lengthKC4)), 
            lengthKC4,0)

bcolor4 = iff( val4 > 0, 
            iff( val4 > nz(val4[1]), lime, green),
            iff( val4 < nz(val4[1]), red, maroon))
scolor4 = noSqz4 ? blue : sqzOn4 ? black : gray 
plot(val4*1.6, color=bcolor4, style=line, linewidth=8, transp=40)
//plot(0, color=scolor4, style=cross, linewidth=4, transp=40)

Image
Bollinger bands of the histogram?

Re: Bollinger Bands type indicators for MT4

Posted: Fri Jun 23, 2023 6:12 am
by chris006
Well, I am a little embarrassed but I do not understand how the extra lines / bollinger bands are calculated. I was hoping you could figure it out from the code.
mrtools wrote: Fri Jun 23, 2023 5:53 am Bollinger bands of the histogram?

Re: Bollinger Bands type indicators for MT4

Posted: Fri Jun 23, 2023 7:19 am
by mrtools
chris006 wrote: Fri Jun 23, 2023 6:12 am Well, I am a little embarrassed but I do not understand how the extra lines / bollinger bands are calculated. I was hoping you could figure it out from the code.
Don't be, it's my bad think i see it in the code just not completely sure how it is plotted. Looks like 3 extra sqz's plotted to change color according to the sqz condition, very interesting. Will see what I can do.

Re: Bollinger Bands type indicators for MT4

Posted: Sun Jun 25, 2023 10:19 pm
by Eslam199199
Is it possible to modify this code so that it makes the alert on every candle that comes out of the range, not just the first candle? Please help

Re: Bollinger Bands type indicators for MT4

Posted: Sun Jun 25, 2023 10:32 pm
by Eslam199199
download/file.php?id=3431420
Is it possible to modify this code so that it alerts on every candle that goes out of the range and not just the first candle? please help

Re: Bollinger Bands type indicators for MT4

Posted: Thu Jun 29, 2023 1:55 am
by dmnik
Does anyone have such a bollinger?

Re: Bollinger Bands type indicators for MT4

Posted: Thu Jun 29, 2023 3:48 pm
by sal
dmnik wrote: Thu Jun 29, 2023 1:55 am Does anyone have such a bollinger?
Image
bro
i think BB is HIGHLOW channel!!.

Re: Bollinger Bands type indicators for MT4

Posted: Thu Jun 29, 2023 9:47 pm
by charli
mrtools wrote: Tue Sep 20, 2022 1:19 pm On/off button added.
Image
Dear Mrtools,is it possible to add option for different deviation for second BB? I am using different deviation of faster bb....Thanks a lot