Any questions from newcomers on MQL4 and MQL5, help and discussion on algorithms and codes - page 1409
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
A question on mql4, more specifically on the ArraySort() function
Here is my code
When LoY[0][0] has got the value Bid( 1.6134) after the order has been opened, the ArraySort(LoY,WHOLE_ARRAY,0,MODE_ASCEND) function has sorted the array in ascending order by the first dimension and has moved the array element with the biggest value to the top of the array. So, LoY[0][0] together with its value becomes LoY[30][0] in the array sorted in ascending order. This is logical and therefore I agree with it.
What in my opinion is not logical or acceptable to me? Why did ArraySort() LoY[15][0] place 0 under the index, despite the fact that its value (1.61040) equals values of all the other array items except the thirtieth. The same is not clear, why ArraySort()LoY[30][0] has put index 15, despite the fact that its value (1.61040) equals the values of all the other elements of the array except for the thirtieth.
A QUESTION: how to make an element with index 0 be LoY[1][0] on this tick , an element with index 15 beLoY[15][0] and an element with index 29 be LoY[30][0]
. In other words, how to make a function not to sort elements with the same value in further? It is not logical and senseless.
Thank you for your help.
This is probably the sorting algorithm. There are some permutations of the array elements.
Try other sorting options.
This is probably the sorting algorithm. There are some permutations of the array elements.
Try other sorting options.
Thank you very much for the advice. Could you please tell me if there are other sorting options in mql4? If so, where are they in the directory?
try it:
although the function is for a one-dimensional array, but it can be reworked
try it:
It's true that the function is for a one-dimensional array, but it can be reworked.
Thank you very much.
A word of advice, please,
The code looks for open charts and creates a label with the name of the symbol, but if two charts have the same symbol,
then it only creates a label on one chart.What am I doing wrong?
A word of advice, please,
The code looks for open charts and creates a label with the name of the symbol, but if two charts have the same symbol,
it only creates the label on one chart.What am I doing wrong?
The chart IDs (ChartID()) of the same symbol are different. Use them.
The ChartID() identifiers of the same symbol are different. Use them.
ChartFirst()+i
i.e. going through all open charts
Or did I misunderstand you? Is there any way to make it clear, in the form of code?
Very strange, on all new open charts puts a mark, only one chart is ignored (
Read the documentation and example code carefully. Your loop is not organised correctly.
Don't tell me that for and while loops work the same way. That's not the problem, it's the highlighted lines.