Skip to main content Heiken Ashi Indicator For ThinkorSwim - Free Download Skip to main content Skip to content
Master the TTM Squeeze with our comprehensive 19-module course Start Learning →
TOS Indicators
  • Tools

    Categories

    • Indicators
    • Backtesters
    • Scans
    • Dashboards
    • thinkScript
    • Member Resources
    Browse Full Library

    Featured Tutorials

    Heiken Ashi Trend Indicator
    Heiken Ashi Trend Indicator
    Indicators

    Download our Custom Heiken Ashi indicator for ThinkOrSwim. Full ThinkScript code, formula...

    Learn more →
    Commodities Tracker
    Commodities Tracker
    Indicators

    For acceleration signals: trend-following strategies and buying pullbacks. For deceleration signals: short...

    Learn more →
    Build an Election Backtester in 10 Minutes
    Build an Election Backtester in 10 Minutes
    Backtesters

    Learn how to create a Post-Election Backtester in ThinkOrSwim to analyze market...

    Learn more →

    Popular Posts

    Unusual Volume
    Unusual Volume
    Scans

    Build 4 scans to easily find stocks with greater than...

    Learn more →
    Upcoming Earnings with High Short Interest
    Upcoming Earnings with High Short Interest
    Scans

    Build a scan to find stocks that are likely to...

    Learn more →
    Unusual Volume Pro Scans
    Unusual Volume Pro Scans
    Scans

    4 additional scans to find unusual volume overlapping with key...

    Learn more →
  • Courses
    Squeeze Course
    Squeeze Course
    19 Modules

    Scan, backtest, and trade the TTM Squeeze setup with precision.

    Unlock Course →
    Earnings Course
    Earnings Course
    3 Modules

    Master earnings plays with free indicators and proven strategies for ThinkOrSwim.

    Unlock Course →
    V-Shaped Reversals
    V-Shaped Reversals
    7 Modules

    Identify and trade powerful V-shaped reversal patterns with confidence and precision.

    Unlock Course →
    Fibonacci Trading
    Fibonacci Trading
    4 Modules

    Learn to trade Fibonacci retracements and extensions in ThinkOrSwim effectively.

    Unlock Course →
  • Products
    Futures Volatility Box Premium
    Futures Volatility Box

    Volatility models for 10 major futures markets, including micros & SPX.

    Explore Futures VB →
    Stock Volatility Box Premium
    Stock Volatility Box

    Dynamic support & resistance for 595+ stocks/ETFs, with a live scanner.

    Explore Stock VB →
    Opening Range Breakouts Premium
    Opening Range Breakouts

    Powerful live scanner & backtester for ORB strategies on 595+ stocks.

    Explore ORB Setups →
My Account
Back to Tutorials
Beginner-Friendly 14 mins ThinkOrSwim

How to Build a Heiken Ashi Trend Dots Indicator in ThinkOrSwim

Download our Custom Heiken Ashi indicator for ThinkOrSwim. Full ThinkScript code, formula breakdown, and tutorial. Free Download!

Download Indicator
How to install in ThinkOrSwim →
Table of Contents
  • What Is Heiken Ashi and Why Traders Use It
  • The Heiken Ashi Formula
  • Why Use Heiken Ashi
  • Building the Indicator Step by Step
  • How to Use the Indicator
  • TradingView (PineScript) Version
  • Limitations

This tutorial walks through building the Heiken Ashi Trend Dots indicator from scratch in ThinkOrSwim. By the end you will have a lower-panel indicator that plots a single colored dot on every bar: green when the trend is confirmed bullish, red when it is confirmed bearish, and yellow during transitions where neither direction has two consecutive bars yet. We build it line by line so you can see what each piece does, not just paste a finished script.

What Is Heiken Ashi and Why Traders Use It

Heiken Ashi means “average bar” in Japanese, and that is the whole concept. Instead of plotting the raw open, high, low, and close on every candle, Heiken Ashi averages those values with the previous bar. The result is a chart that smooths out single-candle noise so trend direction stops flipping on every minor move.

Pull up any ThinkOrSwim chart and you will see a mix of green, red, green, red candles flipping back and forth. That makes it hard to tell whether you are in a real uptrend or just chopping. Because Heiken Ashi averages the data, you get long runs of the same color during real trends. In a clean uptrend you might see eight, ten, even fifteen green candles in a row. When the trend flips, the candle colors flip with it, which makes reversals much easier to spot.

Side-by-side comparison of a standard candlestick chart and a Heiken Ashi chart, showing how Heiken Ashi smooths price action with longer runs of same-colored candles
Standard candlesticks (left) flip color frequently during volatility. Heiken Ashi (right) shows cleaner trends with consecutive same-colored candles.

The Heiken Ashi Formula

Before writing any code, the formula is worth understanding because it makes the rest of the build click. Heiken Ashi has four components.

Heiken Ashi Close. The average of the current bar’s open, high, low, and close. Add the four together, divide by four. ThinkScript has a built-in shorthand for this exact calculation: ohlc4.

Heiken Ashi Open. The average of the previous Heiken Ashi bar’s open and close. This is the recursive piece. Each bar’s open depends on the previous bar’s modified values, not the raw price. That dependency is what creates the smoothing effect.

Heiken Ashi High. The highest of three values: the actual bar high, the Heiken Ashi open, and the Heiken Ashi close.

Heiken Ashi Low. The lowest of those same three values: the actual bar low, the Heiken Ashi open, and the Heiken Ashi close.

The key insight is that the open and close are averages. That is why Heiken Ashi trends appear as long runs of the same color, while raw candlesticks flip on every minor wiggle.

Why Use Heiken Ashi

Three practical benefits.

Trend identification. Long runs of the same color make direction obvious at a glance. Less interpretation, less brain power spent second-guessing the chart.

Fewer false signals. Minor pullbacks inside a trend usually do not flip the candle color. A single red bar inside an uptrend will not shake you out of position because the bar simply stays green.

Cleaner reversals. When the color does change, it tends to mean something. It is not just noise.

The tradeoff is lag. Heiken Ashi will never catch the exact top or bottom because the values are averaged. That is by design. Many traders use Heiken Ashi on a higher timeframe for directional bias and then drop down to standard candlesticks on a lower timeframe (two-minute, five-minute, whatever fits) for actual execution.

Annotated Heiken Ashi chart showing strong uptrend candles with no lower wicks, weakening trends with wicks on both sides, yellow transition zones, and strong downtrend candles with no upper wicks
Reading Heiken Ashi patterns at a glance. Strong trends show same-colored candles with no opposite wicks. Weakening trends develop wicks on both sides. Transition zones mark uncertain direction.

Building the Indicator Step by Step

Now we build it. The plan: a lower-panel indicator that plots a single dot per bar, colored green when two consecutive Heiken Ashi candles are bullish, red when two are bearish, and yellow during transitions. We add the code one piece at a time so you can see what each line does.

Step 1: Create the Study

Open ThinkOrSwim, click the studies icon, then click Create. The code editor panel opens. Name the indicator TI_HeikenAshi_Dots.

Step 2: Declare a Lower-Panel Indicator

The first thing we tell ThinkOrSwim is that this indicator belongs in a lower panel. We do not want it overlaying the price chart.

declare lower;

That single line keeps the indicator below price and out of the way.

Step 3: Calculate the Heiken Ashi Close

The Heiken Ashi close is the average of the current bar’s open, high, low, and close. ThinkScript ships with ohlc4, which gives us exactly that.

declare lower;

def HeikenAshi_Close = ohlc4;

The Heiken Ashi close value is now stored in HeikenAshi_Close.

Step 4: Calculate the Heiken Ashi Open

The Heiken Ashi open is the average of the previous Heiken Ashi bar’s open and close. In ThinkScript, [1] means “the previous bar’s value of this variable.” So we reference HeikenAshi_Open[1] and HeikenAshi_Close[1], add them, divide by two.

declare lower;

def HeikenAshi_Close = ohlc4;
def HeikenAshi_Open = (HeikenAshi_Open[1] + HeikenAshi_Close[1]) / 2;

This is the recursive part. Every bar’s open depends on the previous bar’s values, which is what creates the smoothing.

Step 5: Detect Trend Direction on Each Bar

If the Heiken Ashi close is at or above the Heiken Ashi open, that bar is bullish. If it is at or below, bearish. We capture both as 1/0 flags.

def HeikenAshi_TrendUp = if HeikenAshi_Close >= HeikenAshi_Open then 1 else 0;
def HeikenAshi_TrendDown = if HeikenAshi_Close <= HeikenAshi_Open then 1 else 0;

At this point we know the direction of the current bar. But a single bar is too jumpy to act on. We need confirmation.

Step 6: Require Two Consecutive Bars for Confirmation

Instead of reacting to every bar, we wait for two same-direction bars in a row before calling the trend confirmed. If the current bar is bullish AND the previous bar was bullish, the signal is 1. If both are bearish, the signal is -1. Anything else is neutral (0).

def HeikenAshi_TrendSignal =
    if HeikenAshi_TrendUp == 1 and HeikenAshi_TrendUp[1] == 1 then 1
    else if HeikenAshi_TrendDown == 1 and HeikenAshi_TrendDown[1] == 1 then -1
    else 0;

That extra bar of confirmation is what cuts out the back-and-forth noise you would otherwise get on every bar.

Step 7: Plot a Dot at the Zero Line

Now we put something on the chart. We want one dot per bar, sitting at the zero line in the lower panel. The !IsNan(HeikenAshi_Close) check just confirms we have data for that bar; if we do, plot at zero, otherwise skip it.

plot HeikenAshi_Dots = if !IsNan(HeikenAshi_Close) then 0 else Double.NaN;

Step 8: Make the Dots Visible

By default the plot would draw as a faint line. We want big, obvious dots. Two settings handle that: SetPaintingStrategy tells ThinkOrSwim to render points instead of a line, and SetLineWeight bumps the size. Line weight accepts values from 1 to 5; we use 5, the heaviest.

HeikenAshi_Dots.SetPaintingStrategy(PaintingStrategy.POINTS);
HeikenAshi_Dots.SetLineWeight(5);

Step 9: Color the Dots by Signal

Last piece. Green when the trend signal is 1 (confirmed bullish), red when it is -1 (confirmed bearish), and yellow for everything else (transition or neutral).

HeikenAshi_Dots.AssignValueColor(
    if HeikenAshi_TrendSignal == 1 then Color.GREEN
    else if HeikenAshi_TrendSignal == -1 then Color.RED
    else Color.YELLOW
);

Save the study and apply it to a chart. Green dots line up under confirmed uptrends, red dots under confirmed downtrends, and yellow dots mark the transition zones where direction has not yet flipped both bars in the same direction. The full assembled code is in the Code tab above.

ThinkOrSwim chart with the Heiken Ashi Trend Dots indicator in a lower panel, showing green dots under uptrends, red dots under downtrends, and yellow dots during transition periods
The finished Heiken Ashi Trend Dots indicator on a live ThinkOrSwim chart. Green dots confirm uptrends, red dots confirm downtrends, yellow dots mark transitions.

How to Use the Indicator

The simplest application is to take trades only in the direction of the dots. Longs when dots are green or transitioning yellow-to-green, shorts when dots are red or transitioning yellow-to-red. When dots flip from a confirmed color back to yellow, that is your cue to lighten up, pull back, or get out.

This works as a trend filter, not a complete entry system. Pair it with a trigger you already trust: an Edge Signals indicator, a moving average crossover, or a momentum read like RSI. The trend filter tells you which direction to trade. The trigger tells you when. Together they give you a much more complete picture than either alone.

It works on any symbol and any timeframe. Higher timeframes give you fewer but more reliable signals. Lower timeframes give you more signals at the cost of more noise.

TradingView (PineScript) Version

Trading on TradingView instead of ThinkOrSwim? We have published the same indicator as a free PineScript on TradingView. The logic is identical: Heiken Ashi close and open computed from raw OHLC, two-bar confirmation for trend signal, dots colored green / red / yellow at the zero line in a sub-panel.

Get it here: Heiken Ashi Trend on TradingView. Click Add to favorite indicators and it will be available in your indicators dialog inside the chart.

Limitations

Lag is built in. Heiken Ashi averages price, so signals always trail raw price action. You will never catch the exact top or bottom. Accept it as the cost of a cleaner read.

Modified prices are not real prices. The Heiken Ashi values are averages, not actual OHLC. Do not use them for stop placement or limit-order pricing. Reference standard candles for any price-level decision.

Choppy markets produce yellow. When the market is genuinely sideways, the indicator will sit on yellow and refuse to confirm. That is the indicator working correctly. Either trade a different setup or stand aside until direction returns.

Heiken Ashi Indicator.ts
# TI_HeikenAshi_Dots

# Plots a colored dot per bar in a lower panel based on

# Heiken Ashi trend confirmation:

#   green  = two consecutive bullish HA candles

#   red    = two consecutive bearish HA candles


// ... 11 more lines ...

Unlock This Code

Create a free account to access the full source code and download files.

Create Free Account Login
Heiken Ashi candles use modified OHLC values calculated by averaging price data across consecutive bars. Regular candlesticks show raw price data without any smoothing. This makes Heiken Ashi better for trend identification but unsuitable for precise entry and exit pricing.
The two-candle requirement filters out false signals caused by single-bar reversals. A single color change could be noise. Two consecutive same-colored candles provide stronger confirmation that a real trend shift has occurred. The yellow transition dots alert you when confirmation is pending.
The indicator works on any timeframe, but the appropriate choice depends on your trading style. Day traders often use 5-minute or 15-minute charts. Swing traders may prefer daily charts. Higher timeframes produce fewer but more reliable signals. Lower timeframes generate more signals with more noise.
Yes, but this indicator is designed for a lower panel to keep your main chart uncluttered. To plot Heiken Ashi candles directly on the price chart, you would need a different indicator that replaces or overlays the candle visuals. The Trend Dots approach lets you maintain standard candlesticks for precise price levels while monitoring Heiken Ashi trends below.
The indicator works for any instrument that produces OHLC price data, including stocks, ETFs, futures (ES, NQ, CL), and forex. It does not work for options Greeks or implied volatility displays because those are not OHLC-based. For options trading, use this indicator on the underlying stock or index chart to determine directional bias.
The indicator includes built-in alert inputs. Set useAlerts to yes, then in ThinkorSwim go to Setup > Alerts and create a new alert on the study. You can configure separate sounds for buy and sell signals using the buySound and sellSound inputs. Alerts trigger when haSignal changes from 0 to 1 (bullish) or 0 to -1 (bearish).
A yellow dot indicates a transition period where the trend has not yet been confirmed in either direction. This happens when the current Heiken Ashi candle color differs from the previous candle. The indicator requires two consecutive same-color candles before signaling green (uptrend) or red (downtrend). Yellow dots are periods to wait rather than act.
Yes. Common pairings include using the Trend Dots for direction confirmation alongside volume indicators like RVOL for entry timing, or with support and resistance levels from the Opening Range Breakout. The dots work well as a trend filter: only take long setups when dots are green, short setups when red, and stay flat during yellow transitions.

Here are some resources that you may find useful:

  • How to import an indicator into ThinkOrSwim (video tutorial)
Featured Tools:
Stock Volatility Box

Stock Volatility Box

Spot reversal zones across 600 stocks & ETFs.

  • Hourly & daily models
  • Powerful Live Scanner
  • Built for day traders
Futures Volatility Box

Futures Volatility Box

Pinpoint reversal zones in 10 major futures markets.

  • 5 models (incl. Scalper)
  • ThinkOrSwim & TradingView
  • SPX traders
ORB Setups

ORB Setups

Find the best Opening Range Breakout setups.

  • Powerful real-time scanner
  • Instant backtests
  • 2+ years data

Get Free Access

Create a free account for downloads and new tutorial alerts.

Create Free Account

More Tutorials Like This

Price to Book Value Calculator

Price to Book Value Calculator

Beginner • 12 minutes
Super Bowl Indicator

Super Bowl Indicator

Beginner-Friendly • 25 mins
Cumulative Advance Decline Trading System

Cumulative Advance Decline Trading System

Beginner-Friendly • 11 mins

Ready to Trade With an Edge?

Join 40,000+ traders using institutional-grade tools for ThinkOrSwim.

Get the Bundle
TOS Indicators

Premium thinkorswim indicators, scans, and trading tools to help you trade smarter.

ThinkOrSwim Tools

  • Indicators
  • Scans
  • Backtesters
  • Dashboards
  • thinkScript
  • Browse All

Courses

  • Squeeze Course
  • Earnings Course
  • V-Shaped Reversals
  • Fibonacci Trading

Products

  • Futures Volatility Box
  • Stock Volatility Box
  • ORB Setups
  • Shop All

Guides

  • TTM Squeeze
  • Automated Trading
  • Volatility Trading
  • Opening Range Breakouts
  • Trade Reports
  • Contact Us

© 2026 TOS Indicators. All rights reserved.

Privacy Policy Terms of Service Disclaimer

The information contained on this website is solely for educational purposes, and does not constitute investment advice. The risk of trading in securities markets can be substantial. You must review and agree to our Terms of Service prior to using this site.

U.S. Government Required Disclaimer - Commodity Futures Trading Commission. Futures and options trading has large potential rewards, but also large potential risk. You must be aware of the risks and be willing to accept them in order to invest in the futures and options markets. Don't trade with money you can't afford to lose. This website is neither a solicitation nor an offer to Buy/Sell futures or options. No representation is being made that any account will or is likely to achieve profits or losses similar to those discussed on this website. The past performance of any trading system or methodology is not necessarily indicative of future results.

Individual results may vary, and testimonials are not claimed to represent typical results. All testimonials are by real people, and may not reflect the typical purchaser's experience, and are not intended to represent or guarantee that anyone will achieve the same or similar results.

TOS Indicator's Traders and employees will NEVER manage or offer to manage a customer or individual's options, stocks, currencies, futures, or any financial markets or securities account. If someone claiming to represent or be associated with TOS Indicator solicits you for money or offers to manage your trading account, do not provide any personal information and contact us immediately.

CFTC RULE 4.41 - HYPOTHETICAL OR SIMULATED PERFORMANCE RESULTS HAVE CERTAIN LIMITATIONS. UNLIKE AN ACTUAL PERFORMANCE RECORD, SIMULATED RESULTS DO NOT REPRESENT ACTUAL TRADING. ALSO, SINCE THE TRADES HAVE NOT BEEN EXECUTED, THE RESULTS MAY HAVE UNDER-OR-OVER COMPENSATED FOR THE IMPACT, IF ANY, OF CERTAIN MARKET FACTORS, SUCH AS LACK OF LIQUIDITY, SIMULATED TRADING PROGRAMS IN GENERAL ARE ALSO SUBJECT TO THE FACT THAT THEY ARE DESIGNED WITH THE BENEFIT OF HINDSIGHT. NO REPRESENTATION IS BEING MADE THAT ANY ACCOUNT WILL OR IS LIKELY TO ACHIEVE PROFIT OR LOSSES SIMILAR TO THOSE SHOWN.