I am trying to draw day's fresh high and low on 5 min time frame. But the problem that I am facing is this: it generates new fresh high/low. Requirement: I want one of the following solution a) either it stops after FIRST high or b) gives me the value (lets say 10 EMA) at FIRST instance only which does not change if condition is met again in the same day.
newDayStart = dayofmonth != dayofmonth[1] and
timeframe.isintraday
if newDayStart
dayHighPrice := high
dayLowPrice := low
prevDayClose := close[1]
else
dayHighPrice := math.max(dayHighPrice, high)
dayLowPrice := math.min(dayLowPrice, low)
Fresh_high = close > ( 1.0004*dayHighPrice[1])
Fresh_low = close < (0.9996*dayLowPrice[1])
// barcolor(Fresh_high ? color.rgb(255, 255, 255) : na, title = "Fresh High")
barcolor(Fresh_low ? color.rgb(255, 255, 255) : na, title = "Fresh low")
varip is_day_high_found = false
if (newDayStart)
is_day_high_found := false // Reset the flag when a new day starts
if (not is_day_high_found)
Fresh_high
is_day_high_found := true
barcolor(Fresh_high ? color.rgb(255, 255, 255) : na, title = "Fresh High")