-1.#IND error

 

there is this custom indicator whenever i call it it gets the following value -1.#IND. I checked the corresponding value by cntrl+D there in the data window the value seems to be fine and the indicator is coming out just fine in the indicator window.

the indicator has 3 buffers, 0,1&2. while calling the function using icustom the value in the 3rd buffer i.e. "2" comes out fine. but the other two buffer "0" and "1" print -1.#IND. any insight?

 
cryptex:

there is this custom indicator whenever i call it it gets the following value -1.#IND. I checked the corresponding value by cntrl+D there in the data window the value seems to be fine and the indicator is coming out just fine in the indicator window.

the indicator has 3 buffers, 0,1&2. while calling the function using icustom the value in the 3rd buffer i.e. "2" comes out fine. but the other two buffer "0" and "1" print -1.#IND. any insight?

Show the Indicator code and your iCustom() call please . . .
 
double Buffera[];
double Bufferb[];
double Bufferc[];


int init()
  {

   SetIndexStyle(0,DRAW_LINE);
   SetIndexBuffer(0,Buffera);
   SetIndexStyle(1,DRAW_LINE);
   SetIndexBuffer(1,Bufferb);
   SetIndexStyle(2,DRAW_LINE);
   SetIndexBuffer(2,Bufferc);
   SetLevelValue(0,1);
   SetLevelValue(1,-1);
   ArrayInitialize(Buffera,0.0);
   ArrayInitialize(Bufferb,0.0);
   ArrayInitialize(Bufferc,0.0);
//----
   return(0);
  }

i did a little digging and this came up.

int ArrayInitialize(void array[], double value)
Sets all elements of a numeric array to the same value. Returns the count of initialized elements.
Note: It is not recommended to initialize index buffers in the custom indicator init() function as such functions are initialized automatically with an "empty value" at allocation and re-allocation of buffers. <------------------ seems to the root of the problem. cant find a way out.


 
RaptorUK:
Show the Indicator code and your iCustom() call please . . .

I did say please . . .
 
       z1=iCustom("EURUSD",PERIOD_M1,"ind3",length,maxbars,0,1);
       z2=iCustom("EURUSD",PERIOD_M1,"ind3",length,maxbars,1,1);
       z3=iCustom("EURUSD",PERIOD_M1,"ind3",length,maxbars,2,1);
       
       zp1=iCustom("EURUSD",PERIOD_M1,"ind3",length,maxbars,0,2);
       zp2=iCustom("EURUSD",PERIOD_M1,"ind3",length,maxbars,1,2);
       zp3=iCustom("EURUSD",PERIOD_M1,"ind3",length,maxbars,2,2);
raptor, the error seems to be with the arrayinitialize part tried initializing the array elsewhere but in vain, the indicator lines either disappear or become flat. is there any other way to initialize the array?
 
cryptex:
raptor, the error seems to be with the arrayinitialize part tried initializing the array elsewhere but in vain, the indicator lines either disappear or become flat. is there any other way to initialize the array?

You never mentioned that there was an issue with the Indicator . . .

there is this custom indicator whenever i call it it gets the following value -1.#IND.

. . . is the Indicator broken ?


Can you please post the Indicator code showing the externs . . .

 
i am so sorry. ya the problem is with the indicator. when i load the indicator only one of three lines is visible. so to make to work i double click on the visible line and then click ok when the indicator parameter window pops up. until i thought this might be nothing. but now it dawns upon me that i was just ignoring a big flaw.
#property indicator_separate_window
#property indicator_buffers 3
#property indicator_color1 Lime
#property indicator_color2 Red
#property indicator_color3 Black

//---- input parameters
extern int       length=10;
extern int       maxbars=1000;

double Buffera[];
double Bufferb[];
double Bufferc[];


int init()
  {

   SetIndexStyle(0,DRAW_LINE);
   SetIndexBuffer(0,Buffera);
   SetIndexStyle(1,DRAW_LINE);
   SetIndexBuffer(1,Bufferb);
   SetIndexStyle(2,DRAW_LINE);
   SetIndexBuffer(2,Bufferc);
   SetLevelValue(0,1);
   SetLevelValue(1,-1);
   ArrayInitialize(Buffera,0.0);
   ArrayInitialize(Bufferb,0.0);
   ArrayInitialize(Bufferc,0.0);
//----
   return(0);
  }
 
hey raptor fixed the problem. used this to SetIndexEmptyValue(0,0.0); replace ArrayInitialize(); function :feeling great: apparently you should not use arrayinitialize inside int init (). thanks for your time :D
 
cryptex:
hey raptor fixed the problem. used this to SetIndexEmptyValue(0,0.0); replace ArrayInitialize(); function :feeling great: apparently you should not use arrayinitialize inside int init (). thanks for your time :D
You are welcome . . . by the way, your iCustom() calls look OK
 
zp1=iCustom("EURUSD",PERIOD ...
And why are you hardcoding the pair. That fails on any other pair and on other brokers that have pair adornments (EURUSDm, "EURUSD.", "EURUSD..", "EUR.USD", "EUR/USD", "EURUSD.stp", EURUSDct, "EURUSD.G", "EURUSD+")
 
One thing that i have realized in the past few days is that mql and for that matter any of these high level language are incredibly painful. machine level is so much better :( .The next thing that i am doing is linking mt4 with MATLAB and writing every line of code in MATLAB :D.
Reason: