Machine Learning: kNN-based Strategy

kNN-based Strategy (FX and Crypto)

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
Skrip open-source

Sejalan dengan semangat TradingView, penulis skrip ini telah mempublikasikannya secara open-source, sehingga para trader dapat memahami dan memverifikasinya. Salut untuk sang penulis! Anda dapat menggunakannya secara gratis, tetapi penggunaan kembali kode ini dalam publikasi diatur oleh Tata Tertib. Anda dapat memfavoritkannya untuk dapat menggunakannya didalam sebuah chart.

Inggin menggunakan skrip ini pada chart?


500 coins
+14 Jawab
Nice work!! just a quick question, is there any reason why you used as a k floor(sqrt(252))? wouldn't be better using a high number?
+13 Jawab
capissimo jekojordi88
@jekojordi88, the k value was chosen arbitrarily. On the one hand, small k leads to unstable results. On the other, I wanted to minimize computing cost and tie it up to trading (ex. 252 trading days; might as well use fibo numbers.). Generally, k value is based on the training accuracy.
+7 Jawab
jekojordi88 capissimo
@capissimo, Thanks for the reply. I tried to implement your code in a basic strategy but the outcome is negative. Have you tried as well?
capissimo jekojordi88
@jekojordi88, yes I have. My results were relatively better in higher TFs. It looks this indicator should be used together with other indicators. Besides, I did not explore the fast/slow parameter values. Ple regard it as a proof of concept.)
+1 Jawab
How will i read this?
What is the meaning of symbols? blue, red arrow, plus
+8 Jawab
This publication is now featured in our Editors' Picks: .
In the name of all TradingView traders, thank you for your valuable contribution to the TradingView community, and congrats!
+4 Jawab
capissimo PineCoders
Do they repaint?
+1 Jawab
capissimo thegoodwillhunter
Beranda Penyaring Saham Penyaring Forex Penyaring Crypto Kalender Ekonomi Bagaimana Cara Kerjanya Fitur-Fitur Chart Harga Akun Refer seorang teman Tata Tertib Pusat Bantuan Solusi Website & Broker Widget-Widget Solusi Charting Perpustakaan Charting Ringan Blog & Berita Twitter
Profil Pengaturan Profil Akun dan Penagihan Teman yang di refer Koin Tiket Dukungan Saya Pusat Bantuan Pesan Pribadi Obrolan Keluar