Hi,
First your for loop: You should change bcount > 7 to bcount <= 7, then it actually checks last 7 bars.
Remember that ArrayMaximum returns position of max value in array, for example if largest bar was the fifth,it will return 5.
So in your case you can read your max value with for example range[highestrange], but first change highestrange into integer as it is array index now.
int highestrange; double rangecalc; double range[6]; double array_maximum_value; for (int bcount = 1; bcount <= 7; bcount++) //scan the last 7 prevbars { rangecalc = (High[bcount]-Low[bcount]); //store the range of that candle in the appropriate part of array range[bcount-1] = rangecalc; // bcount -1 because arrays start at 0 } highestrange = ArrayMaximum(range,WHOLE_ARRAY,0); //position of largest bar array_maximum_value = range[highestrange]; //give me the range of the largest candle in the last 7 bars
jacekkrawiec thankyou very much your prompt reply as I said I am no expert
I will go ahead and make the changes and you probably haven't heard the last from me :P
Доброго времени суток уважаемые форумчане!
Меня зовут Герман, мне 23 года, я являюсь трейдером компании "Инстафорекс"
Помогите в поиске нужного скрипта! Скрипт нужен для сетки отложенных ордеров.
![MQL5 - Language of trade strategies built-in the MetaTrader 5 client terminal](https://c.mql5.com/i/registerlandings/logo-2.png)
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
I want this bit of code to scan the last 7 bars, and tell me the highest range.
But all I get is 0's lol. Where did I screw up? P.s Iam still an amateur coder