Machine Learning / Longs

Dec 8, 2020

Static chart image
Signals
Machine Learning
Patterns

The Machine Learning / Longs indicator utilizes a pattern-recognition algorithm to identify potential long entry points by comparing current price action "images" against a stored memory of historically profitable structures. This tool aims to automate the identification of recurring 8-candle formations that have preceded user-defined price increases.

Usage

The Usage section describes how the script can be used to identify bullish setups based on historical similarity.

The script operates in two primary phases: Learning and Searching. During the Learning phase, the indicator scans historical data (starting from the last bar) to find 8-candle sequences followed by a profit increase equal to or greater than the Min Profit setting. These sequences are converted into 64-bit string "images" and stored in an internal array.

In the Searching phase, the tool generates an image of the most recent 8 candles and compares it to all images stored in its memory. If the similarity between the current pattern and a stored pattern exceeds the Similarity Rate, a "Matched" label appears along with a visualization of the historical pattern.

Examples of usage include:

  • Scalping: Setting a lower Period and Min Profit (e.g., 0.2%) to find quick bullish continuation patterns on 1-minute or 5-minute charts.
  • Trend Following: Using a higher Similarity Rate (90%+) on higher timeframes to identify highly specific bottoming or breakout structures.
  • Visual Validation: Comparing the "Current Image" displayed on the chart against the "Matched" historical image to manually verify the context of the signal.

Details

The core of the script is the transformation of price action into an 8x8 grid. The indicator calculates the highest and lowest points of an 8-candle window and divides that vertical range into 8 equal zones. Each cell in the resulting 64-cell matrix is assigned a value based on its contents:

  • 0: Empty
  • 1: Wick only
  • 2: Red body only
  • 3: Green body only
  • 4: Red body and wick
  • 5: Green body and wick

When the price moves up by the Min Profit percentage within the defined Period without dropping below the pattern's low, the 64-character string is saved. The similarity check calculates the percentage of matching characters between strings; if the match meets the threshold, the indicator triggers a signal. Note that this script is experimental and processes memory on the fly; if a calculation timeout occurs, toggling the script visibility will reset the execution.

Settings

General Settings

  • Period: Defines the look-ahead window (in bars) to check if the minimum profit target was achieved after a pattern.
  • Min Profit: The minimum percentage price increase required for a pattern to be considered "successful" and added to memory.
  • Similarity Rate: The percentage threshold required for a current pattern to be considered a match with a stored historical pattern.
  • Max Memory Size: The maximum number of successful patterns the script can store in its array.
  • Change Bar Color?: When enabled, highlights the price bars on the chart when a pattern match is identified.

FAQ

How do I use the "Memory Full" metric?

The Memory Full metric indicates how much of your Max Memory Size has been utilized. If it reaches 100%, the script will stop learning new patterns unless the size is increased or the script is reset.

Why are there no signals on historical bars?

The script is designed to perform its search logic on the most recent bar to optimize performance. To see how it would have performed historically, you can use the TradingView Bar Replay mode.

How can I access Machine Learning / Longs?

You can get access on the LuxAlgo Library for charting platforms like TradingView, MetaTrader (MT4/MT5), and NinjaTrader for free.

Free access on the following platforms
tradingviewSymbolTradingView
Open in your browser

This in-app browser is not compatible with Get Access from the library.

Tap the menu (...) at the top of your screen and select "Open in Browser", "Open in Safari", or "Open in Chrome" to continue.

ninjatraderNinjaTrader
Open in your browser

This in-app browser is not compatible with Get Access from the library.

Tap the menu (...) at the top of your screen and select "Open in Browser", "Open in Safari", or "Open in Chrome" to continue.

metatrader4MetaTrader 4/5
Open in your browser

This in-app browser is not compatible with Get Access from the library.

Tap the menu (...) at the top of your screen and select "Open in Browser", "Open in Safari", or "Open in Chrome" to continue.

thinkorswimThinkorswim
Open in your browser

This in-app browser is not compatible with Get Access from the library.

Tap the menu (...) at the top of your screen and select "Open in Browser", "Open in Safari", or "Open in Chrome" to continue.

Trading & investing are risky and many will lose money in connection with trading and investing activities. All content on this site is not intended to, and should not be, construed as financial advice. Decisions to buy, sell, hold or trade in securities, commodities and other investments involve risk and are best made based on the advice of qualified financial professionals. Past performance does not guarantee future results.

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, including, but not limited to, lack of liquidity. Simulated trading programs in general are designed with the benefit of hindsight, and are based on historical information. No representation is being made that any account will or is likely to achieve profit or losses similar to those shown.

Testimonials appearing on this website may not be representative of other clients or customers and is not a guarantee of future performance or success.

As a provider of technical analysis tools and strategies, we do not have access to the personal trading accounts or brokerage statements of our customers. As a result, we have no reason to believe our customers perform better or worse than traders as a whole based on any content, tool, or platform feature we provide.

Charts used on this site are by TradingView in which the majority of our technical indicators are built on. TradingView® is a registered trademark of TradingView, Inc. www.TradingView.com TradingView® has no affiliation with the owner, developer, or provider of the Services described herein.

Market data is provided by CBOE, CME Group, BarChart, Massive, CoinAPI. Select U.S. equities data is provided through Massive. CBOE BZX real-time U.S. equities data is licensed from CBOE and provided through BarChart. Real-time futures data is licensed from CME Group and provided through BarChart. Select cryptocurrency data, including major coins, is provided through CoinAPI. All data is provided “as is” and should be verified independently for trading purposes.

This does not represent our full Disclaimer. Please read our full disclaimer.

© 2026 LuxAlgo Global, LLC.