AI Trend Navigator

AI Trend Navigator

This article provides a comprehensive guide to the AI Trend Navigator, an advanced technical indicator that leverages a K-Nearest Neighbors (KNN) machine learning logic to identify market trends and predict potential reversals directly within ProRealTime.

What is the AI Trend Navigator?

The AI Trend Navigator is designed to filter market noise by comparing current price action against a historical “window” of data. Unlike standard moving averages that simply lag behind the price, this tool uses a KNN Classifier to find the most similar historical data points (the “neighbors”) and uses their average to project a cleaner, more responsive trend line.

The indicator is highly versatile, allowing users to choose between various calculation methods such as VWAP, Exponential Moving Averages (EMA), and Hull Moving Averages (HMA) for both the data database and the current target.

How It Works: Technical Insights

The core of this indicator is a learning loop that performs the following steps:

  • Database Creation (valueIn): The script calculates a series of historical values based on your chosen source (e.g., Mid-Price, VWAP, or SMA).

  • Target Comparison (targetIn): It identifies the current market state using a separate target calculation.

  • Distance Calculation: For every bar in the historical window (default is 30 bars), the script calculates the absolute “distance” between the current target and past values.

  • KNN Averaging: It identifies the K (number of closest values) smallest distances and averages their corresponding prices to produce the Knn Classifier Line.

  • AI Prediction: It looks back at the 10 most recent patterns to see if similar price movements historically resulted in a bullish or bearish shift, which is then visualized via the background color.

Key Visual Elements

1. The Knn Classifier Line (Thick Line)

This is your primary trend signal. It is dynamically colored based on its slope:

  • Green: The KNN line is rising, indicating a bullish trend.

  • Red: The KNN line is falling, indicating a bearish trend.

  • Orange: The line is neutral or flat.

2. Average Knn Classifier Line (Thin Teal Line)

This line acts as a long-term baseline (smoothed by a Wilder Average). It helps traders distinguish between minor fluctuations and major trend shifts.

3. Predictive Background (Optional)

If enabled, the background provides a visual “forecast” from the AI logic:

  • Green Background: The AI logic predicts a higher probability of an upward move.

  • Red Background: The AI logic predicts a higher probability of a downward move.

Configuration & Settings

You can customize the indicator through the Variables menu in ProBuilder without touching the code.

Input Variable Default Description
priceValue 0

Source for the “Database” (0=HL2, 1=VWAP, 2=SMA, 4=EMA, etc.)

maLen 5

The period used to calculate the database values.

targetValue 0 The current target for comparison (0=Wilder, 1=VWAP, etc.).
numberOfClosestValues 3 The “K” in KNN. Higher values result in more smoothing.
smoothingPeriod 50

Long-term smoothing for the baseline and AI logic.

bgColour 0

Toggle (0 or 1) to enable/disable the predictive background.

ProBuilder Code

The following code should be pasted into the ProBuilder editor. Ensure you define the variables listed above in the “Variables” section of the indicator settings to enable full customization.

Share this

Risk disclosure:

No information on this site is investment advice or a solicitation to buy or sell any financial instrument. Past performance is not indicative of future results. Trading may expose you to risk of loss greater than your deposits and is only suitable for experienced investors who have sufficient financial means to bear such risk.

ProRealTime ITF files and other attachments : How to import ITF files into ProRealTime platform?

PRC is also on YouTube, subscribe to our channel for exclusive content and tutorials

avatar
Register or
Related users ' posts
Iván
1 month ago
roccafragius Thank you!!! Very useful indicator!
josesanbal muchas gracias visualmente una pasada, muchas gracias
Iván No, non è la stessa cosa. Basta guardare il modo in cui vengono calcolati i pivot.
Ciccarelli Franco Quale dei due mi consigli di usare?
Iván A me piacciono i concetti dello smart money, ma è solo la mia opinione.
shephinc When i download it says the file is corrupt and when i try to paste the code something gets ...
Iván if you open the file with V13 you will have no problems. You can copy/paste the original co...
shephinc Aha! Then I just need to figure out how to get v13. Is it released for IG customers?
efahmy Hi Ivan, I have one of your great indicatores to catch reversals, I tried to add voice alert...
Iván you can't use alerts inside indicator. Only works if you create an alarm (from the menu)
Paolo.B Hi Ivan, great work. I'd love to try this indicator in an automated system, but I don't unde...
Maik2404 Hello. It would be very interesting to integrate this indicator into an automated trading sy...
Marc Boliart Hi! i do not know why _v.1.1"] was on 1st line, remember to remove it!
Iván Hola. No puedo arreglarlo. Puedes copiar/pegar (2 segundos) y tienes el indicador... La V...
Harley82 Grazie IVAN per questo lindicatore che mi sembra molto interessante, putroppo, non essendo u...
Iván Buongiorno, la risposta la trovi alle righe 115 e 122, che sono quelle che provocano il camb...
Iván
6 months ago
roccafragius Thank you so much, for my point of view very useful!!!
NicoGB67 Excelente trabajo!!
Jrmjrm Bonsoir est-il possible d'avoir cet indicateur, mais à la place du Wilder Average, utiliser ...
Iván Hi! just change line13 for this: showsignals=1
Quino Hi Excellent indicator as usual. Just 2 questions: Why LenH and LenL = 15 as Len could be...
Iván Hi! good question. This is a code request traslation from other platform. I took same inputs...
Gaspare Grazie Ivan, ottimo indicatore posso chiedere, per favore, una strategia che apre posizio...
Iván thanks! maybe I could test it

Top