I have written a pinescript code. Please help me get rid of this ghost horizontal line. Also appreciate if someone can guide me how to add text on line (price) without adding a label.
indicator("Intraday Assistant", shorttitle="Intraday Assistant", overlay=true)
// User Inputs for customizing lines and labels
showLines = input(true, title="Show Lines") // Default set to false to not show lines
showLabels = input(false, title="Show Labels") // Default set to false to not show labels
lineColorHigh = input(color.green, title="Line Color for High")
lineColorLow = input(color.red, title="Line Color for Low")
lineColorMid = input(color.blue, title="Line Color for Midpoint")
lineWidth = input.int(2, title="Line Width", minval=1, maxval=10)
// Define the market opening time
start_time = timestamp("Asia/Kolkata", year, month, dayofmonth, 09, 15)
// Define variables to store the first candle's high, low, and the first bar index after 9:20
var float firstHigh = na
var float firstLow = na
var float midpoint = na
var int lineStartBarIndex = na // Bar index where lines should start (after 9:20)
// Define today's date
bool today = (year == year(timenow)) and (month == month(timenow)) and (dayofmonth == dayofmonth(timenow))
// Capture the first 5-minute candle's high and low on the correct day and time
if (today and hour == 09 and minute == 15)
firstHigh := high
firstLow := low
// Update the line start index at 9:20
if (today and hour == 09 and minute == 20)
lineStartBarIndex := bar_index
// Calculate Fibonacci levels based on the defined high and midpoint
{
Lines logic
}
// Plot the high, low, midpoint, and Fibonacci retracement levels as horizontal lines on the chart, starting at 9:20
if (showLines and today and not na(firstHigh) and bar_index >= lineStartBarIndex)
// line.new(x1=lineStartBarIndex, y1=firstHigh, x2=bar_index, y2=firstHigh, width=lineWidth, color=lineColorHigh, extend=extend.right)
// line.new(x1=lineStartBarIndex, y1=firstLow, x2=bar_index, y2=firstLow, width=lineWidth, color=lineColorLow, extend=extend.right)
line.new(x1=lineStartBarIndex, y1=midpoint, x2=bar_index, y2=midpoint, width=lineWidth, color=lineColorMid, extend=extend.right)
// Fibonacci levels
line.new(x1=lineStartBarIndex, y1=fib50, x2=bar_index, y2=fib50, width=lineWidth, color=color.orange, extend=extend.right)
line.new(x1=lineStartBarIndex, y1=fib618, x2=bar_index, y2=fib618, width=lineWidth, color=color.purple, extend=extend.right)
line.new(x1=lineStartBarIndex, y1=fib1618, x2=bar_index, y2=fib1618, width=lineWidth, color=color.blue, extend=extend.right)
line.new(x1=lineStartBarIndex, y1=fib2618, x2=bar_index, y2=fib2618, width=lineWidth, color=color.red, extend=extend.right)
line.new(x1=lineStartBarIndex, y1=fib3618, x2=bar_index, y2=fib3618, width=lineWidth, color=color.green, extend=extend.right)
line.new(x1=lineStartBarIndex, y1=fib4236, x2=bar_index, y2=fib4236, width=lineWidth, color=color.yellow, extend=extend.right)
// Plot labels if enabled
if (showLabels and today and not na(lineStartBarIndex))
label.new(x=lineStartBarIndex, y=fib50, text="0.5", color=color.orange, style=label.style_label_down)
label.new(x=lineStartBarIndex, y=fib618, text="0.618", color=color.purple, style=label.style_label_down)
label.new(x=lineStartBarIndex, y=fib1618, text="1.618", color=color.blue, style=label.style_label_down)
label.new(x=lineStartBarIndex, y=fib2618, text="2.618", color=color.red, style=label.style_label_down)
label.new(x=lineStartBarIndex, y=fib3618, text="3.618", color=color.green, style=label.style_label_down)
label.new(x=lineStartBarIndex, y=fib4236, text="4.236", color=color.yellow, style=label.style_label_down)
I have written a pinescript code. Please help me get rid of this ghost horizontal line. Also appreciate if someone can guide me how to add text on line (price) without adding a label.