Please consider which section is most appropriate — https://www.mql5.com/en/forum/172166/page6#comment_49114893
Please read the documentation. The ArrayMaximum returns an index, not a value.
Return Value
The function returns an index of a found element taking into account the array serial. In case of failure it returns -1.
- www.mql5.com
for(int x = PositionsTotal()-1; x>=0; x--)
Besides the issue with ArrayMaximum, your code is also illogical.
If you have already collected all the open prices and know where the maximum value is at in the array, why are you scanning all the positions again.
int max_index = ArrayMaximum(prices,WHOLE_ARRAY,0); double max_price = prices[max_index];
Besides the issue with ArrayMaximum, your code is also illogical.
If you have already collected all the open prices and know where the maximum value is at in the array, why are you scanning all the positions again.
Thanks a lot, your response did help, I have figured out the position (index) of the maximum value.
Hi
Thanks for spotting that error, what an oversight on my part.
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hello Everyone,
Please I need help with a code function in my EA. The Array index works correctly but the Array Maximum gives error value.
Kindly assist to give necessary correction, thanks.