Download MetaTrader 5

Counting past Stochastic data backwards

To add comments, please log in or register
Stefano Specia
44
Stefano Specia  

Hello everybody, I'm trying desperatedly to get the value of past stochastic values over n amount of bars.
The error i get is "'[' array required".
Could you please explain me why iStochastic function wouldn't start on a simple for loop?
Here is my code.

int init(){


int i;  
int Bar=10;
                   
for(i=0;i<Bar-1;i++)
double Stoch=iStochastic(NULL,PERIOD_CURRENT,5,3,3,MODE_SMA,0,MODE_MAIN,0);

Alert(Stoch[i]);
return(0);
}

Many thanks

qjol
3243
qjol  

first of all, don't do it on "init" section, you will probably ran into error 4066

int i;  
int Bar=10;
double Stoch[];
ArrayResize(Stoch, Bar);
for(i=0;i<Bar-1;i++)
   {
   Stoch[i]=iStochastic(NULL,PERIOD_CURRENT,5,3,3,MODE_SMA,0,MODE_MAIN,i);
   Alert(Stoch[i]);
   }
To add comments, please log in or register