Price Prediction By Nearest Neighbor Indicator For MT5

Price Prediction By Nearest Neighbor Indicator For MT5

Table Of Contents:

  1. Price Prediction By Nearest Neighbor Indicator For MT5
  2. Cài đặt Price Prediction By Nearest Neighbor Indicator For MT5
  3. Các tham số của Price Prediction By Nearest Neighbor Indicator For MT5
  4. Bộ đệm của Price Prediction By Nearest Neighbor Indicator For MT5
  5. Các bộ phận chính của bộ luật

Price Prediction By Nearest Neighbor Indicator For MT5 rút ra các biến động giá dự đoán trong tương lai được tính từ các mẫu giá gần đây. Các mẫu giá gần đây được gọi là hàng xóm gần nhất đã đặt tên cho chỉ báo này. Các mẫu giá được sử dụng để tính một biểu quyết có trọng số. Từ kết quả đó, các động thái giá trong tương lai được vẽ trên biểu đồ.

FREE Price prediction by Nearest Neighbor Indicator

Download the FREE Price prediction by Nearest Neighbor Indicator for MT5.

To receive my email 100% sure: 
Put my email on your whitelist!

 

Partially Automated Trading Besides Your Day Job

Alerts In Real-Time When Divergences Occur

 

Cài đặt Price Prediction By Nearest Neighbor Indicator For MT5

Sau khi bạn tải xuống chỉ báo qua biểu mẫu ở trên, bạn cần giải nén tệp zip. Sau đó, bạn cần sao chép tệp nearest_neighbor.mq5 vào thư mục MQL5Indicators cài đặt MT5 của bạn. Sau đó, vui lòng khởi động lại MT5 và sau đó bạn sẽ có thể thấy chỉ báo trong danh sách các chỉ báo.

Các tham số của Price Prediction By Nearest Neighbor Indicator For MT5

Price Prediction By Nearest Neighbor Indicator For MT5 có các tham số 2 để cấu hình.

input int    Npast   =300; // Past bars in a pattern input int    Nfut    =50;  // Future bars in a pattern (must be < Npast) 

Bộ đệm của Price Prediction By Nearest Neighbor Indicator For MT5

Price Prediction By Nearest Neighbor Indicator For MT5 cung cấp bộ đệm 2 .

SetIndexBuffer(0,ynn,INDICATOR_DATA); SetIndexBuffer(1,xnn,INDICATOR_DATA); 

Các bộ phận chính của bộ luật

int OnCalculate(const int rates_total,                 const int prev_calculated,                 const datetime &Time[],                 const double &Open[],                 const double &High[],                 const double &Low[],                 const double &Close[],                 const long &tick_volume[],                 const long &volume[],                 const int &spread[])   { //--- check for insufficient data and new bar    int bars=rates_total;    if(bars lt Npast+Nfut)      {       Print("Error: not enough bars in history!");       return(0);      }    if(PrevBars==bars) return(rates_total);    PrevBars=bars;  //--- initialize indicator buffers to EMPTY_VALUE    ArrayInitialize(xnn,EMPTY_VALUE);    ArrayInitialize(ynn,EMPTY_VALUE);  //--- main cycle //--- compute correlation sums for current pattern //--- current pattern starts at i=bars-Npast and ends at i=bars-1    double my=0.0;    double syy=0.0;    for(int i=0;i lt Npast;i++)      {       double y=Open[bars-Npast+i];       my +=y;       syy+=y*y;      }    double deny=syy*Npast-my*my;    if(deny lt =0)      {       Print("Zero or negative syy*Npast-my*my = ",deny);       return(0);      }    deny=MathSqrt(deny);  //--- compute correlation sums for past patterns //--- past patterns start at k=0 and end at k=bars-Npast-Nfut    ArrayResize(mx,bars-Npast-Nfut+1);    ArrayResize(sxx,bars-Npast-Nfut+1);    ArrayResize(denx,bars-Npast-Nfut+1);        int kstart;    if(FirstTime) kstart=0;    else kstart=bars-Npast-Nfut;    FirstTime=false;    for(int k=kstart;k lt =bars-Npast-Nfut;k++)      {       if(k==0)         {          mx[0] =0.0;          sxx[0]=0.0;          for(int i=0;i lt Npast;i++)            {             double x=Open[i];             mx[0] +=x;             sxx[0]+=x*x;            }         }       else         {          double xnew=Open[k+Npast-1];          double xold=Open[k-1];          mx[k] =mx[k-1]+xnew-xold;          sxx[k]=sxx[k-1]+xnew*xnew-xold*xold;         }       denx[k]=sxx[k]*Npast-mx[k]*mx[k];      }  //--- compute cross-correlation sums and correlation coefficients and find NN    double sxy[];    ArrayResize(sxy,bars-Npast-Nfut+1);    double b,corrMax=0;    int knn=0;    for(int k=0;k lt =bars-Npast-Nfut;k++)      {       //--- Compute sxy       sxy[k]=0.0;       for(int i=0;i lt Npast;i++) sxy[k]+=Open[k+i]*Open[bars-Npast+i];        //--- Compute corr coefficient       if(denx[k] lt =0)         {          Print("Zero or negative sxx[k]*Npast-mx[k]*mx[k]. Skipping pattern # ",k);          continue;         }       double num=sxy[k]*Npast-mx[k]*my;       double corr=num/MathSqrt(denx[k])/deny;       if(corr gt corrMax)         {          corrMax=corr;          knn=k;          b=num/denx[k];         }      }    Print("Nearest neighbor is dated ",Time[knn]," and has correlation with current pattern of ",corrMax);  //--- Compute xm[] and ym[] by scaling the nearest neighbor    double delta=Open[bars-1]-b*Open[knn+Npast-1];    for(int i=0;i lt Npast+Nfut;i++)      {       if(i lt =Npast-1) xnn[bars-Npast+i]=b*Open[knn+i]+delta;       if(i gt =Npast-1) ynn[bars-Npast-Nfut+i]=b*Open[knn+i]+delta;      }     return(rates_total);   } //+------------------------------------------------------------------+ 

 

About Me

I'm Mike Semlitsch the owner of PerfectTrendSystem.com. My trading career started in 2007. Since 2013 I have helped thousands of traders to take their trading to the next level. Many of them are now constantly profitable traders. 

The following performance was achieved by me while trading live in front of hundreds of my clients:

Connect With Me:  

Results From 5 Months!
This service starts soon! Be the first who get's notified when it begins!

This FREE Indicator Can Transform
Your Trading!

FREE Indicator + Telegram Group


Request the Ultimate Double Top/Bottom Indicator which is used by 10,000+ traders.