
Heikin-Ashi (HA) candles are a type of candlestick chart used in technical analysis to identify trends and price direction. The HA formula consists of four calculations that remap open, close, high, and low prices, providing a clear view of market sentiment. When using ThinkScript, a scripting language for ThinkorSwim, traders can plot OHLC (Open-High-Low-Close) candles to visualise price movements. However, some users have reported challenges in plotting HA candles and sought community assistance. While code snippets are shared, there is a focus on understanding the underlying calculations and utilising built-in functions like HeikinAshiDiff() for efficient HA candle analysis in ThinkScript.
| Characteristics | Values |
|---|---|
| Heikin Ashi Formula | Consists of four calculations, which remap Open, Close, High, and Low |
| Open | (Open (previous bar) + Close (previous bar))/2 |
| Close | (Open+High+Low+Close)/4 |
| High | Max Price Reached |
| Low | Max Low Price Reached |
| HA Trend Scan | BkAQSb8 |
| HA Candle Calculations | HA current candle > HA previous candle (higher high); HA previous candle of 2 bars ago was red (HA low of 2 bars ago < HA low of 3 bars ago) |
| Condensed Candles | Signature is a combination of three integer numbers (HO, HC, OL) calculated for each candlestick on the chart |
| Plotting OHLC Candles | plotcandle(open, high, low, close, title='My Chart') |
| Counting UP Candles | Use the SUM function |
Explore related products
$5.98 $6.43
What You'll Learn

Heikin-Ashi formula calculations
The Heikin-Ashi formula consists of four calculations that remap Open, Close, High, and Low. These calculations are used to plot the HA candles.
The first calculation is for the Open and is derived from the formula: Open = [Open (previous bar) + Close (previous bar)]/2.
The second calculation is for the Close and is derived from the formula: Close = (Open+High+Low+Close)/4.
The third calculation is for the High, which is the maximum price reached.
The fourth and final calculation is for the Low, which is the minimum low price reached.
The code for these calculations might look something like this:
Def haOpen = (open [1] + close [1])/2
Def haClose = (open + close + high + low)/4
AssignPriceColor(if haOpen < haClose then color.green else if haOpen > haClose then color.red else color.white)
It is important to note that the Heikin-Ashi formula calculations are not the only aspect of plotting HA candles. The colour of the candles can also be based on the net change from the previous day, with green indicating a higher close and red a lower close than the previous day. The fill of the bar can also be based on the current day's open and close prices, with the bar filled if the open is greater than the close and unfilled if the open is less than the close.
Additionally, the Heikin-Ashi calculations can be used in scans to find matches based on criteria such as the current HA candle being higher than the previous one and the colour of the candles. For example, an upward-trending HA candle is considered bullish, while a downward-trending HA candle is considered bearish.
Furthermore, the SetPaintingStrategy instruction in ThinkScript does not include a style for OHLC candles, but the plotcandle instruction in the TradingView.com scripting language can be used to plot OHLC candles.
Where to Buy Luminara Candles?
You may want to see also
Explore related products

Plotting OHLC candles
To plot OHLC candles in ThinkScript, you can use the 'plotcandle' instruction in the TradingView.com scripting language. Here is the code:
Plotcandle(open, high, low, close, title='My Chart')
This code will plot the OHLC candles with the open, high, low, and close prices as inputs and label the chart as "My Chart".
It is important to note that the script provided by the user only plots OHLC prices as simple lines and not as individual candles. The user is seeking a way to plot the OHLC prices as single candles. Unfortunately, the user has not found a solution in the SetPaintingStrategy instruction, as there is no specific style for OHLC candles.
The Romantic Garden: Haven St. Candle Company's New Scent
You may want to see also
Explore related products

Colouring HA candles
The Heikin-Ashi formula consists of four calculations that remap Open, Close, High, and Low prices. The Open is calculated as the average of the previous bar's open and close, while the Close is the average of the current bar's open, high, low, and close prices. The High is defined as the maximum price reached during the current bar, and the Low is the minimum price reached.
To colour HA candles, you can use conditional statements to assign colours based on the relationship between the current and previous bars. For example, if the current bar's close price is greater than the previous bar's close price, you might colour the current bar's candle green. Conversely, if the current bar's close price is less than the previous bar's close price, you might colour the current bar's candle red.
Def haOpen = (open [1] + close [1]) / 2;
Def haClose = (open + high + low + close) / 4;
AssignPriceColor(if haOpen < haClose then color.green else if haOpen > haClose then color.red else color.white);
In this code, the `haOpen` and `haClose` variables are calculated using the Heikin-Ashi formula. The `assignPriceColor` function then colours the candle based on the relationship between `haOpen` and `haClose`. If `haOpen` is less than `haClose`, the candle is coloured green. If `haOpen` is greater than `haClose`, the candle is coloured red. If neither condition is met, the candle is coloured white.
You can also colour HA candles based on other criteria, such as the net change from the previous day or the relationship between the open and close prices of the current bar. For example, you could colour the candle green if the current bar's close price is greater than the previous day's close price, and red if it is less. Additionally, you can leave the candle unfilled if the open price is less than the close price and fill it if the open price is greater than the close price.
Candles: A Soothing Drug or Just Wax and Wicks?
You may want to see also
Explore related products

Counting HA candles
Counting and calculating HA candles is a key part of stock market analysis and trading. The Heikin-Ashi (HA) formula is a specific set of calculations that remap Open, Close, High, and Low data points. The formula is as follows:
Open = [Open (previous bar) + Close (previous bar)]/2
Close = (Open+High+Low+Close)/4
High = Max Price Reached
Low = Max Low Price Reached
The HA formula is used to plot the HA candles, and the colour of the candles is based on the net change from the previous day. A green candle indicates a higher close than the previous day, while a red candle indicates a lower close. The fill of the candle can also be based on the current day's open and close prices, with an unfilled candle indicating an open lower than the close, and a filled candle indicating the opposite.
When counting HA candles, the goal is often to identify specific patterns, such as consecutive bullish or bearish candles, or candles with a certain shape, like "hammer" or "shooting star" candlesticks. To count the number of HA candles, the SUM function can be used in ThinkScript. For example, to count the number of UP candles, you can define "GreenCandle = Open > Close". This will assign a value of 1 to an UP candle and 0 to a DOWN candle, allowing you to use the SUM function to count the number of UP candles in a given period.
There are also HA trend scanners available, which use code to scan for specific patterns in HA candles, such as consecutive bullish or bearish candles, or the presence of upper or lower wicks. These scanners can be used to identify potential trend reversals and can be customized to suit specific trading strategies.
The Art of Packing Glass Candles
You may want to see also
Explore related products
$18.75 $19.95

Scanning for HA trends
- Open = [Open (previous bar) + Close (previous bar)]/2
- Close = (Open+High+Low+Close)/4
- High = Max Price Reached
- Low = Max Low Price Reached
The Heikin Ashi formula can be used to identify trends and make trading decisions. For example, you can scan for up-trending HA candles with no lower wick for two consecutive candles (bullish) or two down-trending HA candles with no upper wick (bearish). This information can then be used to locate stocks with relative strength or weakness and make informed trading decisions.
Additionally, you can use the built-in function HeikinAshiDiff() to compare the current HA candle with the previous one and identify higher highs or lower lows. This can be useful in determining when a HA candle switches from red to green or vice versa.
ThinkScript also allows traders to create custom indicators and scripts to analyze and scan for HA trends. Traders can develop indicators based on various parameters such as price action, volume, momentum, and volatility, providing valuable insights into market trends and potential entry or exit points. With custom scripts, traders can analyze existing scripts, modify them to suit their needs, and experiment with different trading ideas in a simulated environment.
Overall, ThinkScript offers a flexible and user-friendly environment for traders to gain deeper insights into HA trends and make informed trading decisions.
Goose Creek Candle Company: Where Are They Located?
You may want to see also
Frequently asked questions
The Heiken Ashi hh hl definitions are used to plot HA candles. You can use the plotcandle instruction in TradingView.com scripting to plot OHLC candles.
The Heikin-Ashi Formula consists of four calculations that remap Open, Close, High, and Low: Open = [Open (previous bar) + Close (previous bar)]/2, Close = (Open+High+Low+Close)/4, High = Max Price Reached, and Low = Max Low Price Reached.
You can use the SUM function to count things in ThinkScript. First, define what you want to count. For example, to count the number of up candles, you can define GreenCandle = Open > Close. This will give GreenCandle a value of 1 for an up candle and 0 for a down candle. Then, you can use the SUM function to sum up the values of GreenCandle for the last 10 candles.











































