More than three Candles in a roww 
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © aishshamaishshams


//@version=4
study("Candles", overlay=true)

i_candles = input(3,"Consecutive candles", input.integer)
 


candle_direction    = close >= open ? 1 : -1
sum_direction       = sum(candle_direction, i_candles)

all_up              = sum_direction ==  i_candles
all_down            = sum_direction == -i_candles

barcolor(all_up   ? color.purple : na , offset = -2)
barcolor(all_up   ? color.purple : na , offset=-1)
barcolor (all_up ? color.purple : na )


barcolor (all_down ? color.yellow : na , offset = -2)
barcolor (all_down ?  color.yellow : na , offset = -1)
barcolor (all_down ? color.yellow : na )