On this page
What is an order block?
An order block is the last candle against the move, right before a big candle that breaks away from it. Candle 1 is a down candle. Candle 2 is a big up candle that closes above candle 1's high. Candle 1 is your order block, and the box covers its full range, high to low.
The popular story is that big institutions left orders at that price and defend them when price comes back. I can't see their order books and neither can you, so we don't need that story. The behavior itself is something we can test.
The bearish version is the mirror image: an up candle, then a big down candle that closes below its low. In thinkScript, candle 2 is the current bar and candle 1 is 1 bar back, so the core check on each side is one comparison: close > high[1] for a bull block and close < low[1] for a bear block.
What order blocks did next
Before writing the indicator, I measured every order block on 648 stocks and ETFs using daily bars. Move the filter to see how the size of the big candle changes what happens after it. The indicator's minMove input works the same way.
Still intact 5 days after the first retest
Split by where the retest closed inside the block.
Came back and broke, days after the block
came back broke dashed = minMove 0.5
A retest by itself isn't a buy signal. Five trading days after the first retest, bull blocks returned +0.55% on average, about the same as the +0.50% from any 5-day stretch in the same stocks. Use a block to decide where to look. Use something else to decide when to act.
How this was measured
Universe: 648 stocks and ETFs from our daily bar table, through Oct. 20, 2026. Most symbols start in July 2024, and about 15 index and sector ETFs go back to November 2015, so read this as mostly 2 years of a rising market. A bull block forms on bar i when bar i−1 is a down candle, bar i is an up candle that closes above bar i−1's high, and bar i's high to low range is at least minMove × ATR. The block runs from bar i−1's low to its high. Bear blocks mirror it. Came back: price trades back to the block within N days. Broke: a close through the far edge within N days. Near half and far half: where the first retest closed inside the block, among retests that closed on the right side of the far edge. Intact: no close through the far edge from the retest through 5 bars after it. ATR is the 14-bar simple average of true range, and each block is followed for 20 trading days.
How to read the blocks on a chart
Here's what I look for, using the Apple and SPY charts from the video.

On June 30, 2025, Apple launched higher from one candle. A month later, on August 1, price walked back down into the box, closed above its bottom, and took off again.

SPY left a violet block with a cyan fair value gap right above it. On September 2, 2025, price filled the gap, but the order block underneath held.

Apple's big down candle on December 15, 2025 left a yellow box overhead. On January 2, price traded back up into it and closed back below. By January 6, it had closed through the violet box underneath, which took that box off the chart.
The far edge of the box is your line in the sand. One daily close through it and the idea is done. Before that, watch where the retest closes. In the study, a close in the near half of the block was still good a week later about 6 times out of 10. A close in the far half broke about 2 times out of 3.
You'll see a lot of blocks on a chart. Raise minMove to thin them out, then pair the ones left with a confirmation trigger. I use Edge Signals for that, and the video ends with how I combine them.
How to install the indicator in ThinkOrSwim
- Download the indicator and open the .txt file, then copy all of the code. You can also copy it from the code block on this page.
- In ThinkOrSwim, click the Studies icon, then click Create.
- Delete the placeholder code and paste in the order block code.
- Name the study. I called mine
TI_OrderBlocks. - Click OK, then Apply. Start on a daily chart, which is what the study uses.
New to custom studies? The walkthrough on how to import a thinkScript study into ThinkOrSwim covers the same steps with screenshots.

Inputs
| Input | Default | What it controls |
|---|---|---|
minMove | 1.0 | How big candle 2 has to be, high to low, as a multiple of ATR. Raise it to see only the biggest moves, lower it to see more blocks. |
ATRLength | 14 | Number of bars in the ATR average that minMove is measured against. |
How the code works
Step 1: Inputs and ATR
I need a way to measure what counts as a big push on any stock, so I use ATR as the yardstick. ThinkOrSwim has a built-in ATR function you could call instead. I wrote it out with Average and TrueRange so you can see what it calculates, and pulled the length out as an input.
This step’s code is free with an account. Create one or sign in.
Step 2: Define the big candle
A candle counts as big when its range, high to low, is at least minMove times the ATR. With the default of 1.0, that's one full ATR on your current timeframe.
This step’s code is free with an account. Create one or sign in.
While building this, I used AddChartBubble to check that each condition showed up where I expected it. That's a handy way to debug your own changes, and I took it out of the final code.
Step 3: Define bull and bear order blocks
A bull block has four conditions. The previous bar closed below its open, the current bar closed above its open, the current close is above the previous high, and the current bar is a big candle. The bear side flips each one.
This step’s code is free with an account. Create one or sign in.
Step 4: Carry the box forward without arrays
ThinkOrSwim doesn't have arrays, so I declare bullTop and bullBottom first and set them inside an if/else block. On the bar where a bull block forms, the top and bottom come from the previous candle. On every bar after that, each variable takes its value from the previous bar, which carries the box forward.
This step’s code is free with an account. Create one or sign in.
The middle branch clears the box. Once a candle closes below the bottom of a bull block, both values reset to Double.nan and the box comes off the chart. The bear side mirrors this with a close above the top.
Step 5: Plot the boxes as clouds
If you plot bullTop directly, you get one continuous line that connects each block to the next. To fix that, the plot returns Double.nan on the bar where a block forms, so each new block starts fresh. AddCloud then shades the space between each top and bottom.
This step’s code is free with an account. Create one or sign in.
Full thinkScript code
Create a free account or sign in to copy all 67 lines and download the file.
Video: building the indicator, line by line
31 minutes, from what an order block is to the finished study in ThinkOrSwim. Each chapter opens the video at that point.
How to Build an Order Block Indicator in ThinkOrSwim · 31:33
Limitations
The code is thinkScript. There is no TradingView version.
A new bull block replaces the previous bull block, so older open blocks drop off the chart. Same for bear blocks.
A block shows where price may come back to. It doesn't tell you when to act, and the study found no return edge from the retest alone.
It plots on weekly and intraday charts, but the study only covers daily bars.
To find every stock heading back into a block, you need a scan. That's Part 2, below.
Part 2: the Order Block Scan
Part 2 runs the same logic across a whole watchlist. It has three pieces:
- An upgrade to this indicator that adds a 50% line, so you can see which half of the block a retest closes in.
- A Stock Hacker scan that finds stocks retesting an open order block today.
- A custom scan-tab column that prints each stock's block levels, so you can rank the results.
It ends with how I pair the scan with Edge Signals to time an entry.
Questions
How do I install the Order Blocks indicator in ThinkOrSwim?
Copy the code from this page or the .txt download. In ThinkOrSwim, click Studies, then Create. Delete the placeholder code, paste in the order block code, name the study (I used TI_OrderBlocks), and click OK, then Apply.
What do the violet and yellow boxes mean?
Violet boxes are bull order blocks: the last down candle before a big up candle that closed above its high. Yellow boxes are bear order blocks: the last up candle before a big down candle that closed below its low. Each box covers that candle's full range, high to low, and stays on the chart until a candle closes through it.
What does the minMove input do?
minMove sets how big candle 2 has to be, high to low, as a multiple of ATR. The default of 1.0 means at least one full 14-bar ATR. Raise it to see only the biggest moves, or lower it to see more blocks. It's also the quickest way to thin out a crowded chart.
How often does price come back to an order block?
Across 648 stocks and ETFs, price came back to 84% of order blocks within 20 trading days, about a month. Most of those symbols have about 2 years of daily bars.
When does an order block come off the chart?
A bull block clears once a candle closes below its bottom edge, and a bear block clears once a candle closes above its top edge. A wick through the edge doesn't clear it. A new block on the same side also replaces the previous one.
What's the difference between an order block and a fair value gap?
A fair value gap is the empty space a fast move leaves behind. An order block is the last opposite candle right before that move. They often show up together: 54.3% of the blocks in the study also left a fair value gap on the next candle. The two indicators work well on the same chart.
Does the Order Blocks indicator repaint?
No. The code only looks back, so closed bars never change. On today's live bar, a candle can qualify as the big candle during the session and stop qualifying by the close, like any indicator that reads the current bar. The box draws from the next bar on.
What timeframe should I use?
Start on daily charts, which is what the study uses. The indicator also plots on weekly and intraday charts, and because the ATR comes from the same bars, the minMove filter scales with the chart.
Get each new indicator by email
One email on Sundays with the week's new tool and its code. A free account also unlocks every .txt download.
No credit card. Unsubscribe anytime.
Fair Value Gap
False Breakout Scanner
Heiken Ashi Trend



Stock Volatility Box
Futures Volatility Box
ORB Setups
Squeeze Setups





Anchored VWAP
MTF Squeeze
Market Pulse
Heiken Ashi Trend
Trend Squeeze