INVITE-ONLY SCRIPT

Historical Similarities

6
Happy trading! This tool provides short-term trend estimations. It is a further evolution of my earlier ANN Trend Prediction indicator, but it uses a completely new feature-vector composition and a different type of neural network.

1. Concept
The underlying idea is that history tends to repeat—not exactly, but with recognizable similarities. When recent market conditions resemble past situations, it is reasonable to assume that price may behave similarly again. That is the foundation of this indicator.

In the image below, you can see the general setup. The most recent bar (the “now” point) separates the past from the future. A sequence of recent bars is interpreted as a pattern and fed into a pre-trained LSTM network, which then produces the prediction for the current bar.

ảnh chụp nhanh

The focus of this tool is to deliver predictions as early as possible—ideally just before a trend reversal—to support short-term trades lasting approximately 5 to 20 bars. While perfect early detection is not reached here, this indicator often identifies reversals within one bar after they occur, which is usually early enough to capture meaningful moves.

There are other indicators capable of signaling trend reversals within a single bar—such as Shooting Star or Hammer candle patterns, or certain indicator setups. They were effective when they were new, but widespread use has reduced their reliability, and sometimes those patterns simply do not appear or appear without trend reversal.
This tool, by contrast, is new and it successfully identifies many trend reversals, as demonstrated in the image below:

ảnh chụp nhanh

2. Experimental Part
Furthermore, because this approach offers multiple settings that influence its behavior, you can configure it to focus on larger trends and ignore smaller fluctuations. The following images show several examples:

ảnh chụp nhanh The default settings
ảnh chụp nhanh with only-Body Smoothing enabled
ảnh chụp nhanh with Generalized Trends enabled
ảnh chụp nhanh with both Smoothing enabled

However, as you may notice, when targeting larger trends, a number of false-negative predictions may also appear. These still need to be filtered out. Please keep in mind that this version is experimental, requiring further investigation and research, and I would appreciate any feedback or suggestions.

3. Results
The prediction output is shown through a label and background colors as shown in the following image. It provides probabilities for three market directions:
  • Up - green
  • Sideways - blue
  • Down - red

ảnh chụp nhanh

When the model cannot confidently classify the current market conditions, it deliberately withholds a prediction and leaves the background uncolored. In most cases, however, it displays a label with all three probabilities whenever a new dominant prediction emerges, and it remains visible until the next dominant signal appears.

4. Conclusion
In its default settings, this indicator is quite capable when short-term trends last at least five or more bars. A support-and-resistance indicator can be helpful for setting take-profit and stop-loss levels.


5. Settings Menu

The script is delivered with its default settings, all turned off. However, several configuration options are available:

Input Preparation

Smoothing – Using Heikin Ashi or using only Bar Body are two methods that help remove outliers from the incoming bars.

Generalize Trends – Merges nearby trends together and removes smaller, insignificant trends.

Generalize Patterns – Checks the incoming pattern for artifacts and reduces it when possible. This is a trade-off between removing noise and keeping meaningful features.

Shifting – Examines the incoming pattern for consistency and adjusts it when reasonable.

Speed – Determines how quickly a prediction is calculated. A longer calculation time can improve accuracy, but may also risk the script timing out.


Filters

Intrabar – Off by default, allowing new dominant predictions only at bar close. When enabled, predictions may also be updated intrabar, but this introduces repainting on the current open bar.

Start of Classification – Sets the date from which classifications may begin.

Minimum Gains After Pattern – Defines how much price must rise or fall for a pattern to be considered an up, down, or sideways pattern.

Minimum Classification Probability – If the highest probability is below this threshold, no prediction is selected and the background stays translucent. If one probability exceeds the threshold, the largest one is chosen as the prediction.

Minimum Pattern Strength – Removes patterns whose strength is below this threshold.


6. Alert Signals Available

Trend Signal
  • 2 = possible High
  • 1 = Uptrend
  • 0 = Ranging
  • -1 = Downtrend
  • -2 = possible Low
  • na = no prediction

Signal Age - counts the number of bars since last change


7. Declaration for TradingView House Rules on Script Publishing

The unique feature of the Historical Similarities Indicator is it's nearby real-time detection capability for up trends, down trends and side way price action in most cases.
This script is closed-source and invite-only, to support and compensate for years of development work.

8. Disclaimer

Trading involves risk, and losses can and do occur. This script is intended for informational and educational purposes only. All examples are hypothetical and not financial advice.
Decisions to buy, sell, hold, or trade securities, commodities, or other assets should be based on the advice of qualified financial professionals. Past performance does not guarantee future results.

Use this script at your own risk. It may contain bugs, and I cannot be held responsible for any financial losses resulting from its use.

Cheers!

Thông báo miễn trừ trách nhiệm

Thông tin và các ấn phẩm này không nhằm mục đích, và không cấu thành, lời khuyên hoặc khuyến nghị về tài chính, đầu tư, giao dịch hay các loại khác do TradingView cung cấp hoặc xác nhận. Đọc thêm tại Điều khoản Sử dụng.