Reductionism candle chart
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © BillionaireLau

//@version=5
indicator("Reductionism candle chart",overlay=true)
colorr = input.color(color.blue, "Plot Color")

plot(close,style= plot.style_circles, color = colorr )
plot(open,style= plot.style_circles, color = colorr )
plot(high,style= plot.style_circles, color = colorr )
plot(low,style= plot.style_circles, color = colorr )

dir = close - open
algo = math.abs(dir)
cum_bar_number =  ta.barssince(barstate.isfirst)
init = cum_bar_number<1?1:cum_bar_number>100?100: cum_bar_number
upBound = input(95,title="Volatility boundary of candle")
selector = ta.percentile_nearest_rank(algo, init, upBound)

colorAA = algo> selector and dir>0? color.green : algo > selector  and dir<0? color.red : color.new(color.red, 100)
plotcandle(open, high, low, close, title='Title', color = colorAA, wickcolor=color.new(color.red, 100),bordercolor=color.new(color.red, 100))


