Hello,
First of all, I would like to mention that I am not an expert in mql4 and I would appreciate very much any help about this issue that I am facing. I have spent several hours trying to solve the problem and I couldn't.
The problem:
I am trying to build an indicator that calculates the maximum and minimum of the ATR indicator of the last 100 bars. That means from bar number 1 (index 0) to bar 100 (index 99), I would like to have the maximum and minimum values of that 100 bars range. Then the maximum and minimum of bars 2 to 101, Then from bar 3 to bar 102, and so on. Therefore every new bar finished, a new calculation will be done.
As you can see on the picture below, the ATR indicator is draw fine on the chart from the ATRBuffer[] which contains the values from the iATR. My problem is related to the second loop. How can I get the max and min of the ATR range of 100 bars.
Thank you very much in advance.
Change this:
limit=rates_total-prev_calculated;
if(!prev_calculated)
limit--;
To:
limit = MathMin(rates_total-1, rates_total-prev_calculated);
and you'll start to see lines being drawn...

- 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,
First of all, I would like to mention that I am not an expert in mql4 and I would appreciate very much any help about this issue that I am facing. I have spent several hours trying to solve the problem and I couldn't.
The problem:
I am trying to build an indicator that calculates the maximum and minimum of the ATR indicator of the last 100 bars. That means from bar number 1 (index 0) to bar 100 (index 99), I would like to have the maximum and minimum values of that 100 bars range. Then the maximum and minimum of bars 2 to 101, Then from bar 3 to bar 102, and so on. Therefore every new bar finished, a new calculation will be done.
As you can see on the picture below, the ATR indicator is draw fine on the chart from the ATRBuffer[] which contains the values from the iATR. My problem is related to the second loop. How can I get the max and min of the ATR range of 100 bars.
Thank you very much in advance.