-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBB_color
40 lines (34 loc) · 1.41 KB
/
BB_color
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
//@version=3
study(shorttitle="BB_color", title="Bollinger Bands", overlay=true)
//#71D6FF blue
//#9A9A9A silver
//#EB8836 orange
//#B8DB49 green
// set bollinger band to 18 periods
length_ut = input(18, minval=1)
src_ut = input(close, title="Source")
mult_ut = input(2.0, minval=0.001, maxval=50)
basis_ut = sma(src_ut, length_ut)
dev_ut = mult_ut * stdev(src_ut, length_ut)
upper_ut = basis_ut + dev_ut
lower_ut = basis_ut - dev_ut
// test if boll sup is rising and boll_lower is falling to apply color
dCandles = input(2, minval=2, title="Candles to test Market Direction")
linecolor1 = rising(upper_ut,dCandles) ? #71D6FF : #C0C0C0
linecolor2 = falling(lower_ut,dCandles) ? #71D6FF : #C0C0C0
// draw
plot(basis_ut,title="MM20" , color=#C0C0C0)
p1_ut = plot(upper_ut,title="BB18_U", transp=10,linewidth=3, color=linecolor1)
p2_ut = plot(lower_ut, title="BB18_L", transp=10,linewidth=3,color=linecolor2)
// set bollinger band to 6x18 = 108 periods --> for UT+1
length_UTSUP = input(108, minval=1)
src_UTSUP = input(close, title="Source")
mult_UTSUP = input(2.0, minval=0.001, maxval=50)
basis_UTSUP = sma(src_UTSUP, length_UTSUP)
dev_UTSUP = mult_UTSUP * stdev(src_UTSUP, length_UTSUP)
upper_UTSUP = basis_UTSUP + dev_UTSUP
lower_UTSUP = basis_UTSUP - dev_UTSUP
// draw
p1_UTSUP = plot(upper_UTSUP, title="BB108_U", color=white)
p2_UTSUP = plot(lower_UTSUP, title="BB108_L", color=white)
fill(p1_UTSUP, p2_UTSUP, color=#C0C0C0)