FIBI
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © rareSnow99686

//@version=4
study(title="FIBI", overlay=true)

range_long = input(200, "Range Long", type=input.integer)
range_short = input(100, "Range Short", type=input.integer)

lowest_lr = lowest(open, range_long)
highest_lr = highest(close, range_long)

lowest_sr = lowest(open, range_short)
highest_sr = highest(close, range_short)

fib_lr_618 = lowest_lr + (((highest_lr - lowest_lr) / 100) * 61.80)
fib_lr_114 = lowest_lr + (((highest_lr - lowest_lr) / 100) * 11.40)
fib_lr_236 = lowest_lr + (((highest_lr - lowest_lr) / 100) * 23.60)
fib_lr_786 = lowest_lr + (((highest_lr - lowest_lr) / 100) * 78.60)
fib_lr_382 = lowest_lr + (((highest_lr - lowest_lr) / 100) * 38.20)
fib_lr_50 = lowest_lr + (((highest_lr - lowest_lr) / 100) * 50)
fib_lr_100 = lowest_lr + (((highest_lr - lowest_lr) / 100) * 100)
fib_lr_0 = lowest_lr + (((highest_lr - lowest_lr) / 100) * 0)

fib_sr_618 = lowest_sr + (((highest_sr - lowest_sr) / 100) * 61.80)
fib_sr_114 = lowest_sr + (((highest_sr - lowest_sr) / 100) * 11.40)
fib_sr_236 = lowest_sr + (((highest_sr - lowest_sr) / 100) * 23.60)
fib_sr_786 = lowest_sr + (((highest_sr - lowest_sr) / 100) * 78.60)
fib_sr_382 = lowest_sr + (((highest_sr - lowest_sr) / 100) * 38.20)
fib_sr_50 = lowest_sr + (((highest_sr - lowest_sr) / 100) * 50)
fib_sr_100 = lowest_sr + (((highest_sr - lowest_sr) / 100) * 100)
fib_sr_0 = lowest_sr + (((highest_sr - lowest_sr) / 100) * 0)

line_lr__100 = plot(fib_lr_100, 'LR: 100', color.new(color.gray, 100))
plot(fib_sr_100, 'SR: 100', color.gray, 2, plot.style_stepline,true)

line_lr__786 = plot(fib_lr_786, 'LR: 78.60', color.new(color.blue, 100))
plot(fib_sr_786, 'SR: 78.60', color.blue, 2, plot.style_stepline,true)

line_lr__618 = plot(fib_lr_618, 'LR: 61.8', color.new(color.green, 100))
plot(fib_sr_618, 'SR: 61.8', color.green, 2, plot.style_stepline, true)

line_lr__50 = plot(fib_lr_50, 'LR: 50', color.new(color.white, 100))
plot(fib_sr_50, 'SR: 50', color.white, 2, plot.style_stepline,true)

line_lr__382 = plot(fib_lr_382, 'LR: 38.20', color.new(color.yellow, 100))
plot(fib_sr_382, 'SR: 38.20', color.yellow, 2, plot.style_stepline, true)

line_lr__236 = plot(fib_lr_236, 'LR: 23.60', color.new(color.orange, 100))
plot(fib_sr_236, 'SR: 23.60', color.orange, 2, plot.style_stepline, true)

line_lr__114 = plot(fib_lr_114, 'LR: 11.40', color.new(color.red, 100))
plot(fib_sr_114, 'SR: 11.40', color.red, 2, plot.style_stepline, true)

line_lr__0 = plot(fib_lr_0, 'LR: 0', color.new(color.gray, 100), 2, plot.style_stepline)
plot(fib_sr_0, 'SR: 0', color.gray, 2, plot.style_stepline,true)

fill(line_lr__786, line_lr__100, color=color.new(color.gray, 90), title="LR Fill: 100")
fill(line_lr__618, line_lr__786, color=color.new(color.blue, 90), title="LR Fill: 78.6")
fill(line_lr__618, line_lr__50, color=color.new(color.green, 90), title="LR Fill: 61.8")
fill(line_lr__50, line_lr__382, color=color.new(color.white, 90), title="LR Fill: 50")
fill(line_lr__382, line_lr__236, color=color.new(color.yellow, 90), title="LR Fill: 38.2")
fill(line_lr__236,line_lr__114, color=color.new(color.orange, 90), title="LR Fill: 23.6")
fill(line_lr__0,line_lr__114, color=color.new(color.red, 90), title="LR Fill: 11.4")
