gustgdp: what's going on on my code, since I don't receive an error.
Does this: #property indicator_buffers 1 #property indicator_plots 1
Match this: SetIndexBuffer(0, Feature1, INDICATOR_DATA); SetIndexBuffer(1, Feature2, INDICATOR_DATA); SetIndexBuffer(2, Directions, INDICATOR_CALCULATIONS); SetIndexBuffer(3, Directions, INDICATOR_CALCULATIONS); SetIndexBuffer(4, Predictions, INDICATOR_CALCULATIONS); SetIndexBuffer(5, PredictionLine, INDICATOR_DATA);
Total nonsense.
Average the values read.kNNhandle1 = (RSI1handle + MOM1handle + CCI1handle ) / 3.0; kNNhandle2 = (RSI2handle + MOM2handle + CCI2handle ) / 3.0;
A handle is not a value.
Read in the values.double feature1Value = kNNhandle1; double feature2Value = kNNhandle2;
You do not resize buffers. SetIndexBuffer(4, Predictions, INDICATOR_CALCULATIONS); ⋮ ArrayResize(Predictions, k);
i apologize for the intrusion but won't you need to store the outcome of what you are collecting the kNN distance from somewhere ?
Like , distance from values that have resulted in ... and then tally the votes
And won't you also need the closest k to your stored "knowns" ?![MQL5 - Language of trade strategies built-in the MetaTrader 5 client terminal](https://c.mql5.com/i/registerlandings/logo-2.png)
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Hello everyone, I have searched on the forum but I could not properly identify what's going on on my code, since I don't receive an error.
The code should work like this:
1 - Get the RSI, CCI, and MOM values for the period of 14 and 28;
2 - Average them and respectively insert them in arrays. Feature1 and Feature2;
3 - If Close[0] > Close[1], assign -1 to an array. Else, +1. Store it in Directions;
4 - For the new bar, get the average values from the three indicators in both periods, and calculate the euclidean distance from each of the past values (in this case, 100). So d=sqrt((f1-Feature1)^2 + (f2-Feature2)^2) . Get the k=5 nearest neighbors and retreive their +1 or -1 values on step 3 and put them into an array called Predictions;
5 - Sum the elements in step 4 and plot them with the array PredictionsLine.
My code is compiling without error, but the plot is giving an horizontal line of a fixed value. somewhere in the loop the values are not being updated. Could someone be so kind and take a look?
PS. There are a lot of arrays and handles in the code that are not being used that I am keeping for testing different versions of the code.