iCustom returns 2147483647

Back to topics list To post a new topic, please log in or register
avatar
14
adeller1 2015.08.31 12:16
 

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 

 

 

avatar
211
Subgenius 2015.08.31 12:30 #
 
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

avatar
13008
WHRoeder 2015.08.31 13:58 #
 
   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.
Back to topics list  

To add comments, please log in or register