Price prediction by Nearest Neighbor - indicator for MetaTrader 5

Price prediction by Nearest Neighbor - indicator for MetaTrader 5

The k-Nearest Neighbor algorithm (k-NN) searches for k past patterns (neighbors) that are most similar to the current pattern and computes the future prices based on weighted voting of those neighbors. 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 has the following input parameters:

  • Npast - number of past bars in a pattern;
  • Nfut -number of future bars in a pattern (must be < Npast).

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. For example,

Nearest_Neighbor (EURUSD,H1): Nearest neighbor is dated 2003.08.26 23:00:00 and has correlation with current pattern of 0.9432442047577905;


Price prediction by Nearest Neighbour

Download Price prediction by Nearest Neighbor - indicator for MetaTrader 5

Related News

Latest News
Factbox: Timeline of the Russia doping case
07.12.2019 14:06
LAUSANNE, Switzerland (Reuters) - The World Anti-Doping Agency (WADA) will on Monday consider a recommendation from its compliance committee to hand Russia a four-year Olympic ban as part of a sanctions package to punish Moscow for handing WADA doctored and incomplete laboratory data. Russia, which has denied state involvement in doping, says the
Read more
Germany's SPD slip in polls after choosing new leftist leaders
07.12.2019 14:03
BERLIN (Reuters) - Support for Germany's Social Democrats (SPD) has fallen after members last week chose as leaders a leftist duo who are skeptical about remaining in government with Chancellor Angela Merkel's conservatives, a poll showed on Saturday. At a party conference on Friday, the SPD gave their new leaders, Saskia Esken and
Read more
United States and Iran swap prisoners in rare act of cooperation
07.12.2019 13:06
By Parisa Hafezi DUBAI (Reuters) - The United States and Iran swapped prisoners - a Chinese-American detained for three years on spying charges and an imprisoned Iranian - on Saturday in a rare act of cooperation between two longtime foes whose ties have worsened since President Donald Trump took office. Trump said Chinese-American Xiyue Wang was
Read more
Pope meets with Maltese PM hit by scandal over reporter's murder
07.12.2019 13:03
VATICAN CITY (Reuters) - Pope Francis on Saturday gave a private audience to outgoing Maltese Prime Minister Joseph Muscat, ignoring an appeal to cancel the meeting with a premier engulfed in crisis over a probe into a murdered journalist. Francis met Muscat and his wife and family on Saturday morning, the Vatican said, in an audience that was far
Read more
Buttigieg pledges billions to curb education disparities
07.12.2019 12:15
By Michael Martina DETROIT (Reuters) - Democratic presidential candidate Pete Buttigieg vowed on Saturday to spend hundreds of billions of dollars to improve public education if elected, with a plan that boosts funds for "underserved children" and expands early childhood learning. Buttigieg, who has campaign stops this weekend in Iowa where he has
Read more