OPEN-SOURCE SCRIPT

Ghost Pattern Finder

782
Ghost Pattern Finder searches an instrument’s historical price action for candle patterns that closely resemble a user-selected section of the current chart.

The idea is simple:

If price behaved like this before, what happened next?

Unlike a traditional pattern indicator, the script does not look for predefined formations such as triangles, flags, or head-and-shoulders patterns. Instead, you manually select the price sequence you want to analyze. The indicator then searches the instrument’s own history for similar market behavior and overlays the historical pattern directly on the selected area.

Candle-based Ghost Overlay

The historical match is displayed as a transparent candle overlay rather than only as a line.

This makes it possible to visually compare:

candle bodies
wicks
bullish and bearish sequences
local swings
volatility
acceleration and consolidation phases
the overall shape of the move

The overlay is intentionally semi-transparent so the original chart remains clearly visible underneath it.

Historical Candle Forecast

Once a qualified historical match is found, the candles that actually followed that historical pattern are projected forward.

The projected candles are therefore not generated by AI, regression, or mathematical extrapolation.

They are the real OHLC candles that occurred after the historical match, adjusted to the current price level and time scale.

The forecast should therefore be understood as a historical ghost, not as a guaranteed prediction.

Multi-Timeframe Search

The indicator can search neighboring timeframes automatically.

For example, when used on a 1-hour chart, it can compare patterns from approximately:

15 minutes
30 minutes
1 hour
2 hours
4 hours

A match from another timeframe is not required to have exactly the same number of candles.

Variable Pattern Duration

Historical market structures often develop faster or slower than the current pattern.

For this reason, the indicator also searches different pattern lengths within every timeframe.

By default, historical candidates can range from approximately:

0.5× to 2.0× the duration of the selected pattern.

All candidates are normalized before comparison.

This allows the indicator to recognize similar market behavior even when the historical event unfolded at a different speed.

Strict Ghost Qualification

The script does not simply display the best available candidate.

A historical pattern must pass several independent filters before it is accepted as a Qualified Ghost.

The qualification process evaluates:

overall price-shape correlation
correlation of the most recent part of the pattern
candle-body and wick similarity
swing/directional structure
normalized shape distance
robustness when the comparison window is slightly shortened or shifted

If no candidate meets the selected requirements, the indicator displays:

NO QUALIFIED GHOST

This is intentional. A weak historical similarity should not automatically produce a forecast.

Ghost Stability

Similar matches belonging to the same historical event are grouped into a Ghost Family.

This prevents slightly shifted versions of the same historical pattern from being treated as completely new signals.

The AUTO mode also favors the currently active ghost unless another qualified historical event becomes clearly superior.

The goal is to reduce unnecessary forecast switching when only a few new candles appear.

Multiple Ghosts

The indicator can retain several independent qualified historical matches.

The user can choose:

AUTO
Ghost #1
Ghost #2
Ghost #3
Ghost #4
Ghost #5

This allows manual inspection of alternative historical analogs instead of relying entirely on the algorithm’s highest-ranked candidate.

Adjustable Search Parameters

The settings allow control over:

timeframes included in the search
historical search depth
minimum and maximum pattern-duration scaling
search precision
correlation requirements
tail correlation
candle similarity
swing similarity
robustness
shape distance
ranking weights
ghost-family clustering
ghost switching sensitivity

Preset modes are available for easier use:

Strict, Balanced, Loose and Manual.

Appearance

Overlay and forecast visuals can be customized independently.

Users can adjust:

overlay bullish candle color
overlay bearish candle color
overlay wick color
overlay transparency
forecast bullish candle color
forecast bearish candle color
forecast wick color
forecast transparency
selected-pattern area
invalidation level

This allows the historical ghost to remain visible without hiding the original chart.

How to Use

Select a meaningful section of price action using the Pattern START and Pattern END inputs.

The indicator then:

Builds the selected candle pattern.
Searches historical data across the enabled timeframes.
Tests multiple historical pattern durations.
Scores and filters the candidates.
Groups similar candidates into historical Ghost Families.
Overlays the selected ghost as transparent candles.
Projects the actual historical candles that followed it.

For a conservative workflow, start with Ghost Strictness = Strict.

Important

Ghost Pattern Finder is a historical analog analysis tool.

Markets do not have to repeat previous behavior. A high-quality historical match only means that a similar sequence existed in the past; it does not mean the same outcome will occur again.

The projected candles show what happened after a historical analog, not what must happen next.

The indicator does not place trades and should be used as additional market context rather than as a standalone trading signal.

免責事項

これらの情報および投稿は、TradingViewが提供または承認する金融、投資、取引、またはその他の種類の助言もしくは推奨であることを意図したものではなく、またこれらに該当するものでもありません。詳細は利用規約をご覧ください。