Candle Stick Update
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © samiulgg

//@version=5
indicator(title="Candlestick Style Update", shorttitle="Candlestick Style Update", overlay=true, max_bars_back = 5000)

// Candlestick Style Input
activeBarUpdate = input.bool(true, "Active Candle Style?", group="Candlestick Style", tooltip="Please hide default candle chart (by clicking eye icon) to update this one.")
pline = input.bool(true, 'Show Price Line', tooltip="Please active 'Indicator and financials value labels' from Chart settings -> Scales Tab.", group="Candlestick Style")
barUpdate = input.string("Normal Candles", title="Candlestick Style", options=["Normal Candles", "Heiken Ashi Default", "Heiken Ashi Modified"], group="Candlestick Style")
// Candlestick Color Input
activeBody = input.bool(true, "", inline="Color Candle Body", group="Candlestick Color: Body")
colorBodyUp = input.color(#3179F5, "Up Color", inline="Color Candle Body", group="Candlestick Color: Body")
colorBodyDown = input.color(#787B86, "Down Color", inline="Color Candle Body", group="Candlestick Color: Body")
activeBorder = input.bool(true, "", inline="Color Candle Border", group="Candlestick Color: Border")
colorBorderUp = input.color(#3179F5, "Up Color", inline="Color Candle Border", group="Candlestick Color: Border")
colorBorderDown = input.color(#787B86, "Down Color", inline="Color Candle Border", group="Candlestick Color: Border")
activeWick = input.bool(true, "", inline="Color Candle Wick", group="Candlestick Color: Wick")
colorWickUp = input.color(#5D606B, "Up Color", inline="Color Candle Wick", group="Candlestick Color: Wick")
colorWickDown = input.color(#5D606B, "Down Color", inline="Color Candle Wick", group="Candlestick Color: Wick")
// Variables
// Normal Candles
open_Normal = request.security(ticker.new(syminfo.prefix, syminfo.ticker, session.regular), timeframe.period, open)
high_Normal = request.security(ticker.new(syminfo.prefix, syminfo.ticker, session.regular), timeframe.period, high)
low_Normal = request.security(ticker.new(syminfo.prefix, syminfo.ticker, session.regular), timeframe.period, low)
close_Normal = request.security(ticker.new(syminfo.prefix, syminfo.ticker, session.regular), timeframe.period, close)
// Heiken Ashi Default
open_HA1 = request.security(ticker.heikinashi(syminfo.tickerid), timeframe.period, open)
high_HA1 = request.security(ticker.heikinashi(syminfo.tickerid), timeframe.period, high)
low_HA1 = request.security(ticker.heikinashi(syminfo.tickerid), timeframe.period, low)
close_HA1 = request.security(ticker.heikinashi(syminfo.tickerid), timeframe.period, close)
// Heiken Ashi Modified
var open_HA2 = open
close_HA2 = 0.0
if not na(open_HA2[1])
    open_HA2 := (open_HA2[1] + close_HA2[1]) / 2
    open_HA2
high_HA2 = open > close ? open : close
low_HA2 = open < close ? open : close
close_HA2 := (open_HA2 + high_HA2 + low_HA2 + close) / 4
// Declaration
open_plot = barUpdate == "Heiken Ashi Default" ? open_HA1 : barUpdate == "Heiken Ashi Modified" ? open_HA2 : open_Normal
high_plot = barUpdate == "Heiken Ashi Default" ? high_HA1 : barUpdate == "Heiken Ashi Modified" ? high_HA2 : high_Normal
low_plot = barUpdate == "Heiken Ashi Default" ? low_HA1 : barUpdate == "Heiken Ashi Modified" ? low_HA2 : low_Normal
close_plot = barUpdate == "Heiken Ashi Default" ? close_HA1 : barUpdate == "Heiken Ashi Modified" ? close_HA2 : close_Normal
// Condition
body_col = open_plot > close_plot ? colorBodyDown : colorBodyUp
wick_col = open_plot > close_plot ? colorWickDown : colorWickUp
border_col = open_plot > close_plot ? colorBorderDown : colorBorderUp
// Plot
plotcandle(open_plot, high_plot, low_plot, close_plot, "Candle Colors", color=activeBarUpdate ? activeBody ? body_col : na : na, bordercolor=activeBarUpdate ? activeBorder ? border_col : na : na, wickcolor=activeBarUpdate ? activeWick ? wick_col : na : na)
plot(close_Normal, "Price Line", color = pline ? body_col : na, trackprice = pline ? true : false, style = plot.style_cross)