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?
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.
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. |
Show the Indicator code and your iCustom() call 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?
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 . . .
#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
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
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?