Price prediction by Nearest Neighbor found by a weighted correlation coefficient - indicator for MetaTrader 5




Price prediction by Nearest Neighbor found by a weighted correlation coefficient - indicator for MetaTrader 5


The main disadvantage of the classical Nearest Neighbor algorithm (see an examplary implementation in https://www.mql5.com/en/code/133) is that all prices within a pattern are treated equally. In other words, it assumes that older prices have the same effect on future as newer ones. To overcome this drawback, this version of the nearest neighbor indicator gives larger weights to most recent prices while searching for the closest pattern in the past. It uses a weighted correlation coefficient, whose weight decays linearly from newer to older prices within a price pattern.

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 neighbor and the red curve indicates the future prices of the same pattern. The nearest neighbor 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,

2010.07.09 11:37:10 Nearest Neighbor - weighted corr (EURUSD,H1) Nearest neighbor starts on 2003.02.21 13:00:00 and ends on 2003.03.12 00:00:00. Its correlation coefficient with current pattern is 0.9521726745708775

Price prediction by Nearest Neighbor found by a weighted correlation coefficient


Download Price prediction by Nearest Neighbor found by a weighted correlation coefficient - indicator for MetaTrader 5




Related News




Latest News
Two Expected 2020 IPOs Bring Hope to Egypt’s Subdued Market
10.12.2019 05:15
(Bloomberg) -- Egypt’s ailing stock market could find a much-needed jolt of liquidity from two state-owned enterprises set to go public early next year. The long-awaited initial public offering of one of the biggest banks in the country, Banque du Caire, in particular could draw funds from outside the region, according to Hasnain Malik, head of
Read more
Gold’s Been on a Tear This Year and 2020 May See More Reward
10.12.2019 05:12
(Bloomberg) -- Gold’s impressive advance in 2019 -- aided by trade war frictions, easier monetary policy across the world’s leading economies and sustained central-bank buying -- may be set to spill into the new decade. As 2020 looms, BlackRock Inc (NYSE:BLK)., the world’s largest money manager, remains constructive on bullion as a hedge, while
Read more
Macron Braces for Second Day of Protests Against Pension Reform
10.12.2019 05:09
(Bloomberg) -- Emmanuel Macron is bracing for round-two of a clash with labor unions over his plan to upend France’s pension system, in what could become the defining moment of his presidency. Labor unions will stage a repeat of last week’s mass protests on Tuesday to load pressure the day before Macron’s government announces the final version of
Read more
Japan’s 10-Year Yield Climbs to Zero for First Time Since March
10.12.2019 05:06
(Bloomberg) -- Japan’s 10-year bond yield rose to zero for the first time in nine months amid waning global demand for debt. The nation’s benchmark yields are rising for a fourth month after the Bank of Japan slashed debt purchases and refrained from adding any more easing measures. Bonds have also fallen as optimism that the U.S. and China may
Read more
Australia cartel case against Citi, Deutsche delayed by late night witness statement
10.12.2019 05:03
SYDNEY (Reuters) - An Australian criminal cartel lawsuit against Citigroup Inc (N:C) and Deutsche Bank AG (DE:DBKGn) was postponed on Tuesday after defense lawyers complained the prosecution had given them a redacted statement for a key witness late on the previous day. Though for just one day, the delay raises the chance of pre-trial hearings
Read more