SOLVED: PS This forum kinda had the answer but was too specific and focusing on lines of code not an overall example which worked straight away...
For example
//+------------------------------------------------------------------+ //| Highest Close FOr previous Candles.mq5 | //| Copyright 2020, Anwar Ben Goulouh | //| https://www.mql5.com | //+------------------------------------------------------------------+ #property copyright "Copyright 2020, Anwar Ben Goulouh" void OnTick() { //int for the bar number which is has highest close int HighestClosingBar; //Array to hold closes or opens or highs or whatever double closeArray[]; //Array to hold all data MqlRates ratesData[]; //Sort Arrays downwards ArraySetAsSeries(closeArray,true); ArraySetAsSeries(ratesData,true); //Copy CloseData starting at previous bar and counting back for 5 bars CopyClose(_Symbol,_Period,0,5,closeArray); //Copy all data to data array int priceData=CopyRates(_Symbol,_Period,0,5,ratesData); //Set HighestClosingBar int with the bar number which has the highest close HighestClosingBar=ArrayMaximum(closeArray,0,5); //Get the actual close value for the bar with the highest close and set a variable with the value double closeRate=ratesData[HighestClosingBar].close; //Comment to prove it works Comment ("High Candle Number: ", HighestClosingBar, "\n", "High Candle Close Value: ", closeRate ); }
Can be used for all bar data close, high, low, open, real_volume, spread, tick_volume, time
simply replace CopyClose with CopyHigh etc
and
ratesData[HighestClosingBar].close; with ratesData[HighestClosingBar].High; etc
This may seem to be a silly question, but
why don't you just use iHighest() and iLowest() ?
Haha indeed Mr. Watford.
I am still learning.
I certainly did try for a decent amount of time before asking and doing the above solution, but was unable to correctly interpret other posts/documentation instructions fully.
There's no such thing as a silly question which I am sure my post/Question? could be interpreted as.
Is it a silly question to ask if it is a sillier question to ask why I don't use iHighest() and iLowest() or to answer the first silly question from me?
Are we at three silly questions now.
I'm sure I could eventually develop a trading strategy based on our silly questions...We just need more data.
I will try again.

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hi there,
I am trying to find the highest & lowest closes for the last five bars in an array excluding bar 0.
So far I have this. Can someone please double check this is correct. MQL5
For some reason I am getting an error '=' - illegal operation use when attempting to set highFive and lowFive values.
Any help would be appreciated.
Thanks in Advance