Grid draw
2024-11-04

//@version=5
indicator("GRID DRAW", overlay=true)

// 
highestPrice = input.float(title="Highest Price", defval=100)
lowestPrice = input.float(title="Lowest Price", defval=50)
divisions = input.int(title="Number of Divisions", defval=5, minval=1)

// 
stepSize = (highestPrice - lowestPrice) / divisions

// 
line.new(x1=bar_index , y1=highestPrice, x2=bar_index, y2=highestPrice, color=color.green, width=2)

// 
line.new(x1=bar_index , y1=lowestPrice, x2=bar_index, y2=lowestPrice, color=color.red, width=2)

// 
for i = 1 to divisions - 1
    level = lowestPrice + stepSize * i
    line.new(x1=bar_index , y1=level, x2=bar_index, y2=level, color=color.blue, width=1)