capissimo

Machine Learning: kNN-based Strategy

capissimo Aktualisiert   
kNN-based Strategy (FX and Crypto)

Description:
This strategy uses a classic machine learning algorithm - k Nearest Neighbours (kNN) - to let you find a prediction for the next (tomorrow's, next month's, etc.) market move. Being an unsupervised machine learning algorithm, kNN is one of the most simple learning algorithms.

To do a prediction of the next market move, the kNN algorithm uses the historic data, collected in 3 arrays - feature1, feature2 and directions, - and finds the k-nearest
neighbours of the current indicator(s) values.

The two dimensional kNN algorithm just has a look on what has happened in the past when the two indicators had a similar level. It then looks at the k nearest neighbours,
sees their state and thus classifies the current point.

The kNN algorithm offers a framework to test all kinds of indicators easily to see if they have got any *predictive value*. One can easily add cog, wpr and others.
Note: TradingViews's playback feature helps to see this strategy in action.
Warning: Signals ARE repainting.

Style tags: Trend Following, Trend Analysis
Asset class: Equities, Futures, ETFs, Currencies and Commodities
Dataset: FX Minutes/Hours+++/Days
Versionshinweise:
Added alerts.
Versionshinweise:
An upgrade to Pinescript v.5.
Versionshinweise:
Major Fix. Changedthe signal filter application point and corrected the class label calculation.
Versionshinweise:
Major fix. Added bars count for clear condition variable. Replaced endLongTrade and endShortTrade variables with clear_condition
Versionshinweise:
Minor fix.
Open-source Skript

Ganz im Spirit von TradingView hat der Autor dieses Skripts es als Open-Source veröffentlicht, damit Trader es besser verstehen und überprüfen können. Herzlichen Glückwunsch an den Autor! Sie können es kostenlos verwenden, aber die Wiederverwendung dieses Codes in einer Veröffentlichung unterliegt den Hausregeln. Sie können es als Favoriten auswählen, um es in einem Chart zu verwenden.

Haftungsausschluss

Die Informationen und Veröffentlichungen sind nicht als Finanz-, Anlage-, Handels- oder andere Arten von Ratschlägen oder Empfehlungen gedacht, die von TradingView bereitgestellt oder gebilligt werden, und stellen diese nicht dar. Lesen Sie mehr in den Nutzungsbedingungen.

Möchten Sie dieses Skript auf einem Chart verwenden?