Machine Learning: LVQ-based Strategy
Jan 26, 2021

The Machine Learning: LVQ-based Strategy indicator utilizes a Learning Vector Quantization neural network framework to classify market trends and generate predictive trade signals based on competitive learning.
Usage
The Usage section describes how the script can be used to identify potential market entries and exits through supervised learning classification. Traders can use this tool to determine if specific technical indicators possess predictive value for a given asset.
The script identifies "Buy" and "Sell" opportunities by comparing current market features against trained prototype vectors. When the winning vector indicates a bullish state, a green label appears below the bar; conversely, a bearish state triggers a red label above the bar. Crosses indicate the closure of the current trade.
Signal Filtering
Users can refine signals using the "Filter Signals by" setting:
- Volatility: Only allows signals when short-term ATR exceeds long-term ATR, ensuring trades occur during active market expansion.
- Volume: Filters signals based on a Volume RSI and HMA oscillator to ensure sufficient liquidity.
- Both: Combines both volatility and volume requirements for higher conviction entries.
Details
The LVQ algorithm is a prototype-based supervised learning classification task that trains weights through a competitive, "winner-take-all" approach. Unlike standard backpropagation, LVQ adjusts prototype vectors (weights) in the feature space to better represent specific classes (Buy vs. Sell).
The execution follows these steps:
- Initialization: Weight vectors for bullish and bearish classes are initialized.
- Training: During the user-defined "Training Period," the script processes features—specifically RSI, CCI, and ROC—to adjust the weights based on the learning rate and number of epochs.
- Classification: Once the training period ends, the algorithm uses the Euclidean distance to determine which prototype vector the current market data most closely resembles.
- Signal Generation: The resulting classification is passed through optional filters to produce final visual signals.
Note: This implementation is a predictive model where signals may recalculate as the neural network adjusts to historical data points during its training phase.
Settings
- Dataset: Defines the source price data (default is Close).
- Lookback Window: Sets the period length for the underlying feature indicators (RSI, CCI, ROC).
- Learning Rate: Controls the magnitude of weight adjustments during each training epoch.
- Epochs: The number of times the training process iterates over the data.
- Filter Signals by: Options to filter outputs by Volatility, Volume, or Both.
- Reverse Signals: Inverts the Buy and Sell logic if the model is yielding contrarian results.
- Training Period (Year/Month/Day): Sets the start and stop dates for the supervised learning phase.
- Lot Size: Used to calculate the cumulative return and performance metrics shown in the info panel.
- Show Information: Toggles the visibility of the performance dashboard (Winrate, Profit, Trade count).
FAQ
How do I adjust the sensitivity of the signals? The sensitivity is primarily controlled by the Learning Rate and the number of Epochs. A higher learning rate makes the model more reactive to recent changes, while more epochs allow the model to converge more tightly on historical patterns.
Why are some signals appearing only after the training period? The algorithm requires a designated historical window to "learn" the relationship between the features (RSI, CCI, ROC) and price movement. Signals generated after the "Training Stop Year" are based on the weights established during that initial phase.
How can I access this tool? You can get access on the LuxAlgo Library for charting platforms like TradingView, MetaTrader (MT4/MT5), and NinjaTrader for free.
Unlock Unlimited Access to the LuxAlgo Library
Upgrade your plan to get all indicators, strategies, charts, and full access to Quant, our AI agent.
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.

