Beginner Trading Tutorial — Confirmed Close Location Indicator and Stock Hacker Scan

A candle that closes near its high can be interesting even when its absolute price movement is small. Conversely, a large candle can finish near its midpoint after trading substantially higher during the session. This tutorial builds a simple Thinkorswim study and a matching Stock Hacker filter that measure where the last completed close sits within its own high-low range. The goal is to learn a reusable normalization technique and the distinction between chart studies and Boolean scan scripts, not to claim that a particular candle shape predicts future returns.

Define a normalized measurement

Let H, L and C represent the high, low and close of a completed candle. Subtract L from C, divide by H minus L, and multiply by 100. A valid observation ranges from zero to 100. A close at the low scores zero, a close at the high scores 100, and a close exactly halfway between the two scores 50. Unlike raw distance in dollars, this percentage describes a relative position within the candle. The open is deliberately excluded. A bearish candle can have a high close-location score if it opens even closer to its high.

The calculation is undefined when the high equals the low. Rather than silently assigning zero or 50 to such a candle, the chart study produces a missing value and the scanner rejects it. The scripts also reject missing prices and closes outside the reported range. Set the threshold between zero and 100; the default of 80 selects candles closing in the upper fifth of their range, including the boundary.

Confirmed Close Location Indicator and Stock Hacker Scan
Three independent hypothetical candles share a high of 110 and low of 100. Closes of 109, 108 and 105 produce scores of 90%, 80% and 50%. At an inclusive threshold of 80%, the first two pass.

Calculate the examples manually

For the first candle, the range is ten points and the distance from the low to the close is nine points. The result is 100 × 9 / 10 = 90%. For the second candle the distance is eight points, so the result is 80%. The comparison uses greater than or equal to, meaning that this observation qualifies exactly at the boundary. The third candle has a five-point distance and scores 50%, which fails the filter. These are independent hypothetical observations, not a sequence of actual market prices.

Consider another candle with a high of 11, a low of 10 and a close of 10.9. Its normalized score is also 90% even though its range is only one point. That illustrates the benefit and the limitation of normalization: the indicator compares relative location, but does not distinguish a large range from a tiny one. A separate range or liquidity filter may be useful when researching a broader hypothesis.

Complete chart study in thinkScript

# Confirmed close location study
declare lower;
input threshold = 80.0;
def h = high[1];
def l = low[1];
def c = close[1];
def valid = !IsNaN(h) and !IsNaN(l)
    and !IsNaN(c) and h > l
    and c >= l and c <= h;
plot Location = if valid then
    100 * (c - l) / (h - l) else Double.NaN;
Location.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);
Location.AssignValueColor(if Location >= threshold
    then Color.GREEN else Color.GRAY);
plot Limit = threshold;
Limit.SetDefaultColor(Color.BLUE);

Complete Stock Hacker filter

# Stock Hacker: exactly one Boolean plot
input threshold = 80.0;
def h = high[1];
def l = low[1];
def c = close[1];
def valid = !IsNaN(h) and !IsNaN(l)
    and !IsNaN(c) and h > l
    and c >= l and c <= h;
def score = if valid then
    100 * (c - l) / (h - l) else 0;
plot scan = valid and score >= threshold;

Why the scripts differ

The chart study declares a lower panel and exposes two plots: a histogram for the location and a horizontal threshold line. Color highlights qualifying values. The scanner does not need these visual elements. It defines the same prices and validity condition but exposes exactly one Boolean plot named scan. A rejected observation cannot qualify even when the threshold is zero, because the final expression also requires valid data. Keeping the calculation separate from presentation makes the logic easier to reuse and reduces the risk of mismatched scan and chart results.

The bracket notation [1] references the previous bar relative to the bar being evaluated. In a live chart, the latest histogram value therefore represents the preceding completed candle, not the forming candle. The plot is intentionally displayed one bar later than the source candle. This alignment makes the time of availability explicit and avoids moving a confirmed value backward onto a candle where it was not yet available. The scan uses the same offset. On historical charts, compare the histogram with the OHLC of the candle immediately to its left.

Installation in Thinkorswim

Open Charts, select Studies and Edit Studies, then create a new study in the thinkScript editor. Paste the chart study, assign a descriptive name, save and add it to the chart. Set the aggregation to the timeframe you want to research. Inspect the lower panel and compare its readings with the preceding candle's high, low and close. Change the threshold through the study settings if needed.

For the scanner, open Scan and Stock Hacker, add a Study filter and choose the custom thinkScript editor. Replace the existing script with the scanner version only. Set the filter aggregation to match the chart and run the scan against your chosen universe. Session settings and extended-hours inclusion should also match when comparing results. The scripts use no secondary aggregation. These examples have not been compiled or run in the platform here; confirm acceptance in your installed version before relying on them.

Closed-bar behavior and repainting

The high, low and close of a forming candle can change throughout its lifetime. By referencing the previous candle, both scripts avoid using those provisional prices. A newly completed candle becomes eligible when a subsequent bar is recognized. The filter describes the last completed bar, not a new intrabar event, and may remain true throughout the next bar. Repeated scan results do not represent distinct signals. At a market closure the final candle may not become the previous bar until trading resumes. Data corrections and changes to aggregation or session settings can alter historical readings; this is not a guarantee that all historical data remain immutable.

Testing and limitations

Test closes at the high, low and midpoint, the exact threshold, a zero-range candle and insufficient history. Compare chart and scanner results at the same aggregation and session settings. Observe a live bar transition to confirm the one-bar alignment. A high score is not proof of buying pressure, because OHLC does not reveal the order of trades, volume distribution or market participant intent. It is not a probability of a subsequent gain. The measure ignores gaps, volatility, spread and execution costs. Research any additional filters on independent samples rather than optimizing a threshold against one attractive chart.

For configurable range filters, watchlist columns or custom scan conditions, contact our Custom Thinkorswim indicator Development Services.

Risk disclosure: educational material only. Trading involves risk of loss; hypothetical calculations do not demonstrate profitability.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.