You don't need to use "CopyHigh". There is array of "high".
int OnCalculate(const int rates_total,
const int prev_calculated,
const datetime &time[],
const double &open[],
const double &high[],
const double &low[],
const double &close[],
const long &tick_volume[],
const long &volume[],
const int &spread[])
You are to sum the values of the 5 bars from position i.
for( int i2 = i ; i2 > i - inpPeriod; i2-- )
You need to consider the starting position of the calculation. However, "prev_calculated" should be applied.
for(int i = inpPeriod;i<rates_total && !IsStopped();i++)
Oh your right, thank you very much for help.
Its working fine now.

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
Hi i know about iMA function but my indicator isnt finished like that yet and iMa does not work for my purpose.
What i want is that it takes the last 5 bars and calculate the average, and so on for all 5 bars before like "5 bars -1", "5 bars -2".
The problem is that the indicator is working but not correctly taking the last 5 bars from his position. So i recieve kind of random results.
If i change my start position to 0
Then it works for the current last 5 bars, but the whole buffer is filled with just this value and not calculates last 5 bars -1 ...