calculate the average Closing 10,000 candles

63

I want to calculate the average Closing 10,000 candles is my thank you trying to fix me I'm a beginner can

for(i=1; i<10000; i++)

{

sum +=iClose(Symbol(),NULL,i) ; Num++ ;

Average = NormalizeDouble(sum/Num,5) ;

Print(" Average  ----->  " , Average  ) ;

}

thanks ...

2202

You can also use the "iMA()" function to get an average, but make sure to check if your history has 10000 bars by checking the "Bars" variable, or the "iBars()" function or the more modern "Bars()" function!

```int
BarCount = 10000,
BarShift = 1;

double
BarAverage = 0;

if( Bars >= ( BarCount + BarShift ) )
{
BarAverage = iMA( NULL, 0, BarCount, 0, MODE_SMA, PRICE_CLOSE, BarShift );
Print( "Average for ", BarCount, " is ", DoubleToString( BarAverage, _Digits ) );
}  ```
63

Yes ...

if (Bars < BarCount) { Print("Not enough bars");

thank you it s work .....

2202

jeef_1985:

Yes ...

if (Bars < BarCount) { Print("Not enough bars");

thank you it s work .....

Actually, there was a bug in my initial post. I have revised it to be:

`if( Bars >= ( BarCount + BarShift ) )`
63

I have try with a lower number of bars to test
normally the average is the sum of two terminals it works now thank you