ANN Strategy v2
Nov 8, 2015

The ANN Strategy v2 indicator utilizes a multi-layer Artificial Neural Network (ANN) to predict price movements based on percentage differences across multiple timeframes. This tool processes historical price data through an input layer, two hidden layers, and an output layer to generate non-repainting long and short signals for trend-following strategies.
Usage
The Usage section describes how the script can be used, examples should be provided in this section. This tool is primarily designed to identify trend shifts by analyzing the relationship between a high-timeframe anchor and the current chart timeframe.
- Signal Interpretation: When the ANN output exceeds the positive threshold, the script generates a "Long" signal and highlights the background green. When the output falls below the negative threshold, a "Short" signal is triggered with a red background.
- Timeframe Correlation: Users should set the "Timeframe" setting to a higher period (e.g., 1 Day) while viewing a lower timeframe chart (e.g., 4 Hour). The script calculates the percentage difference between the current price and the previous anchor period's OHLC/4 value to feed the neural network.
- Threshold Adjustment: The threshold setting acts as a filter; increasing it can reduce market noise by requiring a stronger neural network prediction before a signal is triggered.
Details
The script implements a feed-forward neural network architecture directly within Pine Script. The process begins by fetching the ohlc4 (average of Open, High, Low, and Close) from a user-defined higher timeframe using request.security.
The core logic involves:
- Input Layer: Calculates the percentage change between the current price and the previous anchor period.
- Hidden Layers: The input is processed through 5 neurons in the first hidden layer and 33 neurons in the second hidden layer. These layers use a Hyperbolic Tangent (Tanh) activation function to handle non-linear relationships.
- Output Layer: Aggregates the weighted values from the hidden layers into a single prediction value (
l3_0). - Stability: Unlike the previous version, this iteration uses historical data from the anchor timeframe to prevent repainting, ensuring that signals remain fixed once the bar closes.
Settings
- Threshold: Determines the sensitivity of the signals. A value of 0.0000 triggers signals on any polarity flip, while higher values require more significant model confidence.
- Timeframe: Defines the higher timeframe used as the reference point for calculating price deltas.
FAQ
How do I adjust the sensitivity of the ANN Strategy v2? You can adjust the "Threshold" setting in the script inputs. A higher threshold will result in fewer, more selective signals, whereas a lower threshold will increase signal frequency.
Why is the background color changing? The background color reflects the current bias of the neural network. Green indicates a bullish prediction based on the model's weighted calculations, while red indicates a bearish prediction.
How can I access the ANN Strategy v2? You can get access on the LuxAlgo Library for charting platforms like TradingView, MetaTrader (MT4/MT5), and NinjaTrader for free.
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.

