Machine Learning: kNN-based Strategy (update)

kNN-based Strategy (FX and Crypto)


This update to the popular kNN-based strategy features:
improvements in the business logic,
an adjustible k value for the kNN model,
one more feature (MOM),
a streamlined signal filter and
some other minor fixes.

Now this script works in all timeframes !

I intentionally decided to publish this script separately
in order for the users to see the differences.
Versionshinweise: Major fix: added scaling function for the mom feature. Mom requires scaling to the range of .
Open-source Skript

Ganz im Sinne von TradingView hat der Autor dieses Skripts es als Open-Source veröffentlicht, damit Trader es verstehen und überprüfen können. Ein Hoch auf den Autor! Sie können es kostenlos verwenden, aber die Wiederverwendung dieses Codes in einer Publikation unterliegt den Hausregeln. Sie können das Skript den Favoriten hinzufügen, um es auf dem Chart zu verwenden.

Möchten Sie dieses Skript auf einem Chart verwenden?


Why is this not drawing the last few indicators? For me, it seems to not draw the indicators in realtime, as if it cuts off the last few predictions.
+7 Antworten
JokingPips bluiska
@bluiska, i second this. @capissimo do we need to wait for a few close candles for it to calculate or is there something wrong?
First of all thanks for that great script and the awesome content you are producing for this community!

I would like to ask if this updated version is still repainting?
+3 Antworten
capissimo walfgott
@walfgott, unfortunately, yes. Hopefully, this community will find the proper way.
Perhaps you should turn it into a strategy and wait for the signal to be triggered on the bar close after the signal condition has been met. On the exits then you could use a strategy.exit to exit in that precise moment instead. but these are just my 2cents.
+1 Antworten
capissimo Minimal_Est
@Minimal_Est, I prefer not to and leave it to the users. You propose to use a black box magic.
+1 Antworten
Minimal_Est capissimo
@capissimo, black box magic ?
capissimo Minimal_Est
+1 Antworten
Hi guys,
I tested the script with Fast Period = 23 , Slow Period = 32 and Dataset = Low and the winrate changes to 72% for BTC M5!! Does anyone change the properties to get better results?
Thanks for the awesome update on your KNN AI script. A couple of questions on this script:
1. It appears to me that the tthres input should be a number between 0 - 1, and not 0.1 - 100 because the variable barlife is a ratio of tcurr/tbase which appears to be a ratio of 0 - 1 for each bar. So I am confused why the input for tthres goes up to 100 instead of 1.0?

2. Could you explain the holding period input and how the input values are used and how they effect the functioning of the script? Thx GF