Trend candles
Heikin Ashi Calculator
Turn one regular candle into a Heikin Ashi candle. Enter the bar's open, high, low and close, plus the previous Heikin Ashi open and close, or leave those two empty for the first bar.
What Heikin Ashi candles are
Heikin Ashi, Japanese for average bar, is a way of drawing candles from averaged values so that a series of bars looks smoother than regular candlesticks. Each Heikin Ashi candle is built from the regular bar and from the previous Heikin Ashi candle.
The close is the average of the regular open, high, low and close. The open is the average of the previous Heikin Ashi open and close. The high is the largest of the regular high, the Heikin Ashi open and the Heikin Ashi close, and the low is the smallest of the regular low and those same two values. The first bar has no previous candle, so its open is seeded as the average of the regular open and close.
Why Heikin Ashi is used
Because the values are averaged, Heikin Ashi candles are often used to describe the persistence of a move: runs of same-colored candles, and the presence or absence of wicks. The trade-off is that the open, high, low and close shown are no longer actual traded prices, so they should not be read as levels where orders could have been filled.
Because each open depends on the previous candle, the series is path dependent: the same bar can give a different candle depending on where the chart starts. How you read the candles is entirely your own analysis.
What are TradingView and Pine Script?
TradingView is one of the most widely used charting and market-analysis platforms, where traders and analysts study price movement across stocks, crypto, forex, and futures on interactive charts. Pine Script is TradingView's own lightweight programming language, created so anyone can build custom tools that run directly on those charts.
People use Pine Script to build four main kinds of tools. Indicators calculate and plot values on the chart, exactly like the calculation above, but recomputed automatically on every bar. Strategies add explicit entry and exit rules and can be backtested against historical data in TradingView's Strategy Tester to see how they would have behaved. Screeners scan many symbols at once for conditions you define. Alerts notify you the moment a condition you specified occurs, so you do not have to watch the screen.
The value is precision and automation. Instead of eyeballing a chart, you describe exactly what you want measured, visualized, or notified about, and TradingView runs it consistently across any market and timeframe. That is why traders, analysts, and developers write Pine Script: it turns a manual charting idea into a repeatable tool. These tools are for tracking, visualizing, and testing market ideas; they do not tell you what to trade, and that decision always remains yours.
Writing that code by hand means learning Pine Script's syntax, its type system, and the exact names of hundreds of built-in functions. It is a real programming language, and small mistakes stop a script from compiling in the Pine Editor.
Turn this into Pine Script
This calculator gives you one candle. On a chart the series has to carry the previous Heikin Ashi open forward on every bar, which is what the code above does. Wiring those candles into alerts or strategy logic is where most of the work lives.
//@version=6
indicator("Heikin Ashi Candles", overlay=true)
haClose = (open + high + low + close) / 4
float haOpen = na
haOpen := na(haOpen[1]) ? (open + close) / 2 : (haOpen[1] + haClose[1]) / 2
haHigh = math.max(high, haOpen, haClose)
haLow = math.min(low, haOpen, haClose)
haColor = haClose >= haOpen ? color.teal : color.red
plotcandle(haOpen, haHigh, haLow, haClose, "Heikin Ashi", color=haColor, wickcolor=haColor, bordercolor=haColor)PineScripter is an AI built specifically for Pine Script. You describe what you want in plain English and it writes TradingView-ready v6 code. Because it is specialized on the Pine Script language and its exact function signatures, it tends to produce code that compiles far more reliably than general-purpose models like ChatGPT, which often invent functions that do not exist in Pine Script.
Related free calculators
From the blog
PineScripter is an AI developer tool that helps you write Pine Script code. It is not a financial advisor and will never offer financial, investment, or trading advice. Everything on this page, including the calculator and the explanations, is provided purely for educational and informational purposes. Any decision about how to interpret an indicator or trade a market is entirely your own. See our full disclaimer for more.