Grid Indicator - The Quant Science
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © thequantscience

//@version=5
indicator("Grid Indicator - The Quant Science", overlay = true)

price = input.price(defval = 0, title = "Price:", confirm = true) 
price_range = input.float(defval = 0.50, title = "Price range: ", confirm = true)

grid1up     = price + ((price_range/2) * price / 100)
grid1down   = price - ((price_range/2) * price / 100)
grid2up     = grid1up + ((price_range) * price / 100)
grid2down   = grid1down - ((price_range) * price / 100)
grid3up     = grid2up + ((price_range) * price / 100)
grid3down   = grid2down - ((price_range) * price / 100)
grid4up     = grid3up + ((price_range) * price / 100)
grid4down   = grid3down - ((price_range) * price / 100)
grid5up     = grid4up + ((price_range) * price / 100)
grid5down   = grid4down - ((price_range) * price / 100)

plot(grid1up, color = color.rgb(119, 255, 0))
plot(grid1down, color = color.rgb(255, 0, 0))
plot(grid2up, color = color.rgb(119, 255, 0))
plot(grid2down, color = color.rgb(255, 0, 0))
plot(grid3up, color = color.rgb(119, 255, 0))
plot(grid3down, color = color.rgb(255, 0, 0))
plot(grid4up, color = color.rgb(119, 255, 0))
plot(grid4down, color = color.rgb(255, 0, 0))
plot(grid5up, color = color.rgb(119, 255, 0))
plot(grid5down, color = color.rgb(255, 0, 0))