I need some help. TIME FRAME = 5 mins. I want an indicator to plot the open and high till the first opposite color candle. Basically:
First candle positive and second candle negative, then plot high and low for the first 10 mins (price range of first two candles).
First candle positive and second candle positive and third candle negative, then plot high and low for the first 15 mins (price range of first two candles).
First candle is positive and second candle positive and third candle positive and the fourth candle is negative, then plot high and low for the first 20 mins (price range of first 4 candles).
I am getting the error: Mismatched input 'if' expecting 'end of line without line continuation'
// Declare a variable to track if the first red candle has been found
first_red_candle = false
// Declare variables to store the high and low of the day after the first red candle
high_after_first_red = na
low_after_first_red = na
// Iterate through the candles
for i = 0 to bar_index
// Check if the current candle is red
if close[i] < open[i]
// Check if this is the first red candle
if not first_red_candle
// Set the first red candle flag to true
first_red_candle = true
// Otherwise, update the high and low of the day after the first red candle
else
high_after_first_red := max(high_after_first_red, high[i])
low_after_first_red := min(low_after_first_red, low[i])
// Plot the high and low of the day after the first red candle
plot(high_after_first_red)
plot(low_after_first_red)