Cant seem to get stochastic cross to work

 
//--------------------------------------------------------------------
// tradingexpert.mq4 
// The code should be used for educational purpose only.
//--------------------------------------------------------------------
#define MainBuffer 3
#define SignalBuffer 4
#define HighesBuffer 5
#define LowesBuffer 6

#define Price MODE_CLOSE // Choose one


#property copyright "Copyright © Book, 2007"
#property link      "http://AutoGraf.dp.ua"
//--------------------------------------------------------------- 1 --
                                   // Numeric values for M15
extern int    Period_1= 200;      // Period of MA 1
extern int Period_bars= 200;
extern double lot = 1;

extern int sto = 0;
extern int stos= 0;

extern int KPeriod=200;
extern int DPeriod=100;
extern int Slowing=100;

bool Work=true;                    // EA will work.

//--------------------------------------------------------------- 2 --
int start()
  {   double sto;
   double stos;
   bool Ans  =false;                     // Server response after closing
//--------------------------------------------------------------- 3 --
   // Preliminary processing
   if(Bars < 100 )                       // Not enough bars
     {
      Alert("Not enough bars in the window. EA doesn't work.");
      return;                                   // Exit start()
     }
   if(Work==false)                              // Critical error
     {
      Alert("Critical error. EA doesn't work.");
      return;                                   // Exit start()
     }
//--------------------------------------------------------------- 4 --
   // Trading criteria
 sto=iCustom(NULL,0,"Stochastic",KPeriod,DPeriod,Slowing,2,1);
 stos=iCustom(NULL, 0, "Stochastic",KPeriod,DPeriod,Slowing,1,1);
 
 static int stos.prev;
  static int sto.prev;


if ( stos.prev < sto.prev && stos >= sto ){ //0.2
      Alert("stoa");
}

if ( stos.prev > sto.prev && stos <= sto ) {
      Alert("teststs");
}


 stos.prev=stos;
 sto.prev=sto;
//--------------------------------------------------------------- 9 --
   return;                                      // Exit start()   
  }
 
It fails because the values from stoch are double and not int.
 

still cant,

is there another way to get the stos.prev/sto.prev values aka from previous bars.

the icustom shift just makes things crazy.

 

i modified it a little.. help?

//--------------------------------------------------------------------
// tradingexpert.mq4 
// The code should be used for educational purpose only.
//--------------------------------------------------------------------
#define MainBuffer 1
#define SignalBuffer 2
#define HighesBuffer 3
#define LowesBuffer 4

#define Price MODE_CLOSE // Choose one


#property copyright "Copyright © Book, 2007"
#property link      "http://AutoGraf.dp.ua"
//--------------------------------------------------------------- 1 --
                                   // Numeric values for M15
extern int    Period_1= 200;      // Period of MA 1

extern int KPeriod=200;
extern int DPeriod=100;
extern int Slowing=100;
double stos[2];
double stos2[2];

bool Work=true;                    // EA will work.

//--------------------------------------------------------------- 2 --
int start()
  {  
   int    counted_bars=IndicatorCounted();
   double sto;
   double stos;
   bool Ans  =false;                     // Server response after closing
//--------------------------------------------------------------- 3 --
   // Preliminary processing
   if(Bars < 50 )                       // Not enough bars
     {
      Alert("Not enough bars in the window. EA doesn't work.");
      return;                                   // Exit start()
     }
   if(Work==false)                              // Critical error
     {
      Alert("Critical error. EA doesn't work.");
      return;                                   // Exit start()
     }
//--------------------------------------------------------------- 4 --
   // Trading criteria
 sto[0]=iCustom(NULL,0,"Stochastic",KPeriod,DPeriod,Slowing,2,0);
  sto[1]=iCustom(NULL,0,"Stochastic",KPeriod,DPeriod,Slowing,2,1);
 stos[0]=iCustom(NULL, 0, "Stochastic",KPeriod,DPeriod,Slowing,1,0);
  stos[1]=iCustom(NULL, 0, "Stochastic",KPeriod,DPeriod,Slowing,1,1);

if ( (stos[1] > sto[1]) && (stos[0] <= sto[0] ) ) { //0.2
      Alert("test1a");
}

if ( (stos[1] < sto[1]) && (stos[0] >= sto[0] ) ) { //0.2
      Alert("test2a");
}


 
//--------------------------------------------------------------- 9 --
   return;                                      // Exit start()   
  }
 

Latest that compiles

/*Alerts when stochastic crosses the lower or upper threshold.*/


extern int KPeriod=200;
extern int DPeriod=100;
extern int Slowing=100;
double sto[2];
double stos[2];

//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
   sto[0] = iCustom(NULL,0,"Stochastic",KPeriod,DPeriod,Slowing,2,0);
  sto[1] = iCustom(NULL,0,"Stochastic",KPeriod,DPeriod,Slowing,2,1);
 stos[0] = iCustom(NULL, 0, "Stochastic",KPeriod,DPeriod,Slowing,1,0);
  stos[1] = iCustom(NULL, 0, "Stochastic",KPeriod,DPeriod,Slowing,1,1);
  
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//----
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
   int    counted_bars=IndicatorCounted();
    sto[0] = iCustom(NULL,0,"Stochastic",KPeriod,DPeriod,Slowing,2,0);
  sto[1] = iCustom(NULL,0,"Stochastic",KPeriod,DPeriod,Slowing,2,1);
 stos[0] = iCustom(NULL, 0, "Stochastic",KPeriod,DPeriod,Slowing,1,0);
  stos[1] = iCustom(NULL, 0, "Stochastic",KPeriod,DPeriod,Slowing,1,1);

if ( (stos[1] > sto[1]) && (stos[0] <= sto[0] ) ) { //0.2
      Alert("test1a");
}

if ( (stos[1] < sto[1]) && (stos[0] >= sto[0] ) ) { //0.2
      Alert("test2a");
}

 return(0);
  }
//+------------------------------------------------------------------+
 
??
Reason: