iCustom returns 2147483647

 

Hello, 

 

For learning purposes I'm looking at this simple indicator called test2 (basic ma cross)


#property indicator_chart_window
#property indicator_buffers 3
#property indicator_color1 Aqua
#property indicator_color2 Purple

double Uparrowposition[];
double Downarrowposition[];
double signal[];


int FEMA = 14;
int SEMA = 84;
int RSIPeriod = 14;

bool Gi_100 = FALSE;
bool Gi_108 = FALSE;


int init() {
   SetIndexStyle(0, DRAW_ARROW, STYLE_SOLID, 5);
   SetIndexArrow(0, SYMBOL_ARROWUP);
   SetIndexBuffer(0, Uparrowposition);
   SetIndexStyle(1, DRAW_ARROW, STYLE_SOLID,5);
   SetIndexArrow(1, SYMBOL_ARROWDOWN);
   SetIndexBuffer(1, Downarrowposition);
   SetIndexStyle(2, DRAW_NONE);
   SetIndexBuffer(2, signal);

   
   return (0);
}
int deinit() {
   return (0);
}

int start() {
   int j;
   double fastema;
   double slowema;
   double fastemashift;
   double slowemashift;


   double cc;
   double dd;
   int Li_100 = 2000;
   if (Li_100 < 0) return (-1);
   if (Li_100 > 0) Li_100--;
   int Li_0 = Bars - Li_100;
   for (int i = 0; i <= Li_0; i++) {
      j = i;
      cc = 0;
      dd = 0;
      for (j = i; j <= i + 9; j++) dd += MathAbs(High[j] - Low[j]);
      cc = dd / 10.0;
      fastema = iMA(NULL, 0, FEMA, 0, MODE_EMA, PRICE_CLOSE, i);
      fastemashift = iMA(NULL, 0, FEMA, 0, MODE_EMA, PRICE_CLOSE, i + 1);
    
      slowema = iMA(NULL, 0, SEMA, 0, MODE_EMA, PRICE_CLOSE, i);
      slowemashift = iMA(NULL, 0, SEMA, 0, MODE_EMA, PRICE_CLOSE, i + 1);

    
            
      
      if (fastema > slowema && fastemashift < slowemashift ) {
          Uparrowposition[i] = Low[i] - 1.9 * cc;      
          signal [i] = 1;
      } 
      else {
          if (fastema < slowema && fastemashift > slowemashift ) {
               Downarrowposition[i] = High[i] + 1.9 * cc; 
               signal [i] = 2;
           }
           else {
               signal[i] = 0;
   }   
      
}
}
   return (0);
}

 

 

I'm trying  to use it in an expert avisor using the third buffer as a signal 

iCustom(  Symbol(), 0, "test2", TEST2_VALUE_3, 0 )

 

 I'm hoping to trigger the buy signal when iCustom returns 1, and sell when it returns 2.

 However the iCustom value always returns 2147483647 or Empty Value

 

Any idea which basic mistake I'm doing ?

Regards 

 
adeller1:

how do we know anything without it being in the code, and knowing what indicator?

comment all possibilities, open data window and run tester. thats what i do.

your icustom must have the inputs, probably save a copy of your indicator without inputs just

for the expert, thats what i do.

"\n" is a new line

 
   int Li_100 = 2000;
   if (Li_100 < 0) return (-1);
   if (Li_100 > 0) Li_100--;
   int Li_0 = Bars - Li_100;
   for (int i = 0; i <= Li_0; i++)
Won't calculate anything unless you have 2000 bars.
Reason: