AutoLevels
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © steven_eth

//@version=5
indicator('ATR FibLevels', overlay=true,explicit_plot_zorder = true)
length = input.int(14, minval=1, title='ATR Length')
atr = ta.atr(length)
TF = input.timeframe(title='Timeframe', defval='D')
current_day_open = request.security(syminfo.tickerid, TF, open[0],lookahead=barmerge.lookahead_on )
atr_value_at_current_day_open = request.security(syminfo.tickerid, TF, atr[1], lookahead=barmerge.lookahead_on)
mult1 = (.236) 
mult2 = (.382) 
mult3 = (.618) 
mult5 = (1)    
u_mult1 = current_day_open + atr_value_at_current_day_open / 2 * mult1
u_mult2 = current_day_open + atr_value_at_current_day_open / 2 * mult2
u_mult3 = current_day_open + atr_value_at_current_day_open / 2 * mult3
u_mult5 = current_day_open + atr_value_at_current_day_open / 2 * mult5
l_mult1 = current_day_open - atr_value_at_current_day_open / 2 * mult1
l_mult2 = current_day_open - atr_value_at_current_day_open / 2 * mult2
l_mult3 = current_day_open - atr_value_at_current_day_open / 2 * mult3
l_mult5 = current_day_open - atr_value_at_current_day_open / 2 * mult5
line1 = plot(u_mult1,color=u_mult1 != u_mult1[1] ? na : color.rgb(76, 175, 79, 10), linewidth=1)
line2 = plot(u_mult2, color=u_mult2 != u_mult2[1] ? na : color.rgb(76, 175, 79, 10), linewidth=1)
plot(u_mult3, color=u_mult3 != u_mult3[1] ? na : color.rgb(175, 147, 76))
line4 = plot(u_mult5, color=u_mult5 != u_mult5[1] ? na : color.rgb(175, 147, 76))
line9 = plot(l_mult1, color=l_mult1 != l_mult1[1] ? na : color.rgb(221, 48, 48, 10), linewidth=1)
line10 = plot( l_mult2, color=l_mult2 != l_mult2[1] ? na : color.rgb(221, 48, 48, 10), linewidth=1)
plot(l_mult3, color=l_mult3 != l_mult3[1] ? na : color.rgb(175, 147, 76))
line12 = plot(l_mult5, color=l_mult5 != l_mult5[1] ? na : color.rgb(175, 147, 76))




