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

//@version=5
indicator("Close Candles", overlay =  true)

OHLC(src, int len = 4) =>
    Open  = ta.sma(src[1], len)
    High  = ta.highest(src, 1)
    Low   = ta.lowest(src, 1)
    Close = ta.wma(src, len)
    [Open, High, Low, Close]

src   = input.source(close, "Source")
len   = input.int(4, "Length")
sel   = input.bool(true, "Candle Colour", "Chance how the candles are colored. If this is enabled it will color the candles bassed on the transformed open/close. Otherwise this indicator will use source/source[1]")

red   = input.color(color.new(#ef5350, 0), "")
green = input.color(color.new(#26a69a, 0), "")

[Open, High, Low, Close] = OHLC(src, len)

colour = sel ? Open < Close ? green : red : src > src[1] ? green : red
plotcandle(Open, High, Low, Close, "RSI Candle", colour, colour, true, bordercolor = colour)
