https://www.tradingview.com/script/b7Jt ... C-Candles/
Code: Select all
// This Pine Script® code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © LuxmiAI
//@version=6
indicator('Heikin Ashi Colored Regular OHLC Candles', overlay = true, behind_chart = false)
// Calculate Heikin Ashi values
haClose = (open + high + low + close) / 4
var float haOpen = na
haOpen := na(haOpen[1]) ? (open + close) / 2 : (haOpen[1] + haClose[1]) / 2
haHigh = math.max(high, math.max(haOpen, haClose))
haLow = math.min(low, math.min(haOpen, haClose))
// Determine Heikin Ashi candle direction
isBull = haClose > haOpen
isBear = haClose < haOpen
// Assign candle color based on HA direction
bullColor = color.lime
bearColor = color.red
neutralColor = color.gray
candleColor = isBull ? bullColor : isBear ? bearColor : neutralColor
// Plot actual candles with HA color scheme
plotcandle(open, high, low, close, color = candleColor, wickcolor = candleColor, bordercolor = candleColor)