-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbb_fibonacci.pinescript
More file actions
32 lines (28 loc) · 1.6 KB
/
bb_fibonacci.pinescript
File metadata and controls
32 lines (28 loc) · 1.6 KB
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
//@version=5
indicator("Bollingers Bands Fibonacci ratios 4 lines",shorttitle="FiBB4",overlay=true, timeframe="", timeframe_gaps=true)
length=input.int(defval=20,minval=1)
src = input(close, title="Source")
offset = input.int(0, "Offset", minval = -500, maxval = 500)
mult = array.new_float(4)
dev = array.new_float(4)
upper = array.new_float(4)
lower = array.new_float(4)
basis = ta.sma(src,length)
array.set(mult, 0, input.float( 2.0, minval=0.001, maxval=50, title="StdDev1"))
array.set(mult, 1, input.float( 2.618, minval=0.001, maxval=50, title="StdDev2"))
array.set(mult, 2, input.float( 3.618, minval=0.001, maxval=50, title="StdDev3"))
array.set(mult, 3, input.float( 4.618, minval=0.001, maxval=50, title="StdDev4"))
dev_base = ta.stdev(src, length)
for it = 0 to 3
array.set(dev, it, array.get(mult, it) * dev_base)
array.set(upper, it, basis + array.get(dev, it))
array.set(lower, it, basis - array.get(dev, it))
plot(basis, "Basis", color=#FF6D00, offset = offset, display=display.none)
plot(array.get(upper, 3), "upperEX", color=color.rgb(255, 0, 0), offset = offset, style=plot.style_circles)
plot(array.get(upper, 2), "upper3", color=#ff3535, offset = offset)
plot(array.get(upper, 1), "upper2", color=#ff3535, offset = offset)
plot(array.get(upper, 0), "upper", color=#ff3535, offset = offset)
plot(array.get(lower, 0), "lower", color=#7ee57e, offset = offset)
plot(array.get(lower, 1), "lower2", color=#7ee57e, offset = offset)
plot(array.get(lower, 2), "lower3", color=#7ee57e, offset = offset)
plot(array.get(lower, 3), "lowerEX", color=color.rgb(0, 255, 0), offset = offset, style=plot.style_circles)