Download MetaTrader 5

Indicators: Price prediction by Nearest Neighbor

To add comments, please log in or register
Automated-Trading
Admin
102536
Automated-Trading  

Price prediction by Nearest Neighbor:

This indicator uses the Nearest Neighbor clustering technique, also called k-NN, to search for the most similar pattern in history and use its past prices as predictions of the current pattern future prices.

The present indicator finds only one nearest neighbor. So, in essence, it is a 1-NN algorithm. It uses the Pearson correlation coefficient between the current pattern and all past patterns as the measure of distance between them.

The indicator plots two curves: the blue curve indicates the past prices of the nearest neighbour and the red curve indicates the future prices of the same pattern. The nearest neighbour is scaled according to the linear regression slope between this pattern and the current pattern. The indicator also prints the information about the starting date of the nearest neighbor and its correlation coefficient to the present pattern.

Author: Vladimir

Price prediction by Nearest Neighbour

q_import
858
q_import  
Very Nice
Vladimir
5958
Vladimir  

q_import:
Very Nice

 

Thanks.

johnmcgiles
34
johnmcgiles  

I can't add comments to your most recent nearest neighbor post so I'm going to ask a question in this one.  First off, thank you for submitting this, I find it very interesting, but how do you get the future indicator values using this?  I'm using the code below to get the indicator's prediction 50 bars in the future, but this is just an intuitive guess as to how it should work, is this right?   

int nearestNeighborHandle = iCustom(_Symbol,_Period,"nearest_neighbor_-_weighted_corr",300,50);

double  indicatorValues[];

if( CopyBuffer(nearestNeighborHandle,0,-50,50,indicatorValues) < 0 )  {} 

 

Thank you. 

dee544
119
dee544  

 

many thanks for your interesting indicator.
If I use your indicator in a strategy, I get the following output:

I suspe
ct that the calculation nearst neighbor with the number of bars starts. Is that correct?

Regards

dee544  

 

MathQuant
73
MathQuant  

Thank You


Hooshang Nosratpanah
69977
Hooshang Nosratpanah  
Great
Kevin Manrrique
292
Kevin Manrrique  
Is this version also available for MT4?
To add comments, please log in or register