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

  1. adeelq79 • 15 hours ago #

    Nice indicator. Works well when combined with 9EMA and other indicators.

avatar
Register or

Likes

avatar
Related users ' posts
Nicolas
7 years ago
Maxime Baudin Interesting, Thank you! :)
franck-david Bonjour Nicolas , actuellement je me forme grace a vos videos tres tres bien expliques mer...
Nicolas Merci. ça n'est pas le lieu pour poser ce genre de question :) Merci d'utiliser le forum Pro...
Vonasi Discussion on this indicator/filter can be found here: https://www.prorealcode.com/topic/121...
Domenec Claro Juanjo de todas maneras en deinversoratrader.com tienes estsos osciladores evolucionad...
Dron Hola Domenec, en la descripción hablas del indicador velas de colores, no lo encuentro en la...
Domenec Hola Dron mira en el blog deinversoratrader.com en formacion indicadores ahi hay varios grat...
Geronima Ortiz I watched the video three times, but I can not put the npips parameter as a variable. I do...
Geronima Ortiz I think the video is for an old version of prorealtime, the images do not correspond at all ...
Nicolas indicator1 = CALL “PRC_StopReversal”[npips, 1] and define npips in the optimization window ...
Caribeengeek Bonjour j’avais vu que vous proposiez d’écrire des codes pour ceux qui s’y connaisse pas Mai...
Caribeengeek Les devises unité
Nicolas Merci d'utiliser le forum pour les demandes de programmation personnalisée
ullle73 nicolas, can you somehome make this to be in the background of the price chart?
jonpt88 none did that yet right?
Nicolas You can ask for a code modification on forums, please open a new topic with your request.
Toto le Heros Thanks Nicolas. I read somewhere that in the calculation, we should round the value of the A...
Nicolas aADX = round(adx[10])
bolsatrilera
8 years ago
Rainbow Oscillator
Rainbow Oscillator
1
Indicators
Maxime Baudin Interesting, thanks! Combine this indicator with the bollinger bands there is enough to make...
supertiti Bonsoir à tous For those who like me want to calibrate this indicator on a scale of 0 to ...
verdi55 You can find me at www.FXautomate.com Ahh. So i got it ? 4 different supertrends without th...
juanj What? This has nothing to do with the website. The site is simply a service to help people ...
Nicolas Advertising is allowed,as long as people are helping others and if provided services are abo...
styrke Hello Nicolas, Nice screener, I appreciate the way you always try to condense at maximum th...
Nicolas There's no particular reason. RSI is widely use with its default period and results seems re...
Vonasi I noticed a couple of typo errors in the code. The list of variables lines 4 to 11 should be...
Genotik Thank you for your important contribution this week which is much appreciated! Happy New Yea...
Vonasi No problem. I hope they are useful to someone. Happy and hopefully prosperous New Year to y...
DarioMazza Hi Vonasi, i have a question for you, the comand "pricetype" where did you found it in the ...
Vonasi PriceType is just a variable that I use. The value decides what type of price is used in the...
Vonasi I noticed a couple of typo errors in the code. The list of variables lines 4 to 11 should be...
Nicolas
8 years ago
Trinity Impulse
Trinity Impulse
5
Indicators
ribou ah d'accord merci beaucoup
domenico nlevel1 non modifica la curva al variare del suo valore
tiger_man_no1 Very nice ; what is the best period input date for DAILY CHART ?
Nicolas
8 years ago
Genotik Merci !
WarningTrading Comment peut on la comparer ? comme ceci ? cela ne me donne plus le message d'erreur manque...
sally31120 Bonjour, je n'arrive pas à créer ce screener close > supertrend extended2[1] la réponse...
Nicolas voir ce sujet pour un screener basé sur Supertrend Extended: https://www.prorealcode.com/top...
Marcel For those who are interested, I post trade opportunities with this indicator on Twitter. (@M...
swapping Thank you for sharing, best regards
Tellie2015 tack ska du ha för dina delningar både här o twitter
Leo Hi all, I posted a new version of this indicator ( I just add arrows to spot the local maxi...
Trading_En_El_Ibex35 Muchas Gracias por compartir este interesante indicador. Un saludo
xavieralava hola gracias leo

Top