Calculating SMA for strategies
Generaly,it should be close[].
I have had difficulty in passing the array.
here is my code in the main program:
double close_fast[50],close_slow[100],close_veryslow[150];
CopyClose(_Symbol,PERIOD_D1,0,FastEntry,close_fast);
double FastEntryMA=SimpleMA(0, 50,close_fast);
the error i get is
2011.09.18 19:25:30 Core 2 2011.05.02 00:00:00 Array out of range in 'MovingAverages.mqh' (19,12)
- www.mql5.com
double close_fast[50],close_slow[100],close_veryslow[150];
>>Modified to:
double close_fast[],close_slow[],close_veryslow[];
hello the Moving Average file includes this function:
double SimpleMA(const int position,const int period,const double &price[])
{
//---
double result=0.0;
//--- check position
if(position>=period && period>0)
{
//--- calculate value
for(int i=0;i<period;i++) result+=price[position-i];
result/=period;
}
//---
return(result);
}
What price array should I pass to the function when calculating on a Symbol? Thanks