My iCustom code always return empty value (2147483647)----------------------(second edition)

Back to topics list To post a new topic, please log in or register
avatar
9
pacman992 2016.01.15 15:44
 

this is the indicator code

#property indicator_buffers 2

double var_a[];
double var_b[];

int init(){
   SetIndexBuffer(0, var_a);
   SetIndexBuffer(1, var_b);
 
return (0);
}

int start(){

double getMainTrend;
double getMainTrend2;

getMainTrend = iMACD(NULL, Maintrend_TimeFrame, 8, 17, 9, PRICE_CLOSE, MODE_SIGNAL, 0); //assume this line is correct
getMainTrend2 = iMACD(NULL, Maintrend_TimeFrame, 8, 17, 9, PRICE_CLOSE, MODE_MAIN, 0); // this too

count = IndicatorCounted();
int pos = Bars - count;

while(pos-1>0)
   {
      var_a[pos]=getMainTrend;
      var_b[pos]=getMainTrend2;
	pos--; Alert("var_a = "+var_a[pos]+ " var_b = "+var_b[pos]); //this code return values
}

return (0);
}

int deinit(){
return (0);
}

 and this is the expert advisor

#property strict

int init(){
return(0);
}

int start(){
        double val_a = iCustom(NULL,0,"indicator",0,1); //i'm not sure about this line
	double val_b = iCustom(NULL,0,"indicator",1,1); //i'm not sure about this line
        alert("value A = "+ val_a); //this code return empty value
	alert("value B = "+ val_b); //this code return empty value

return(0);
}

int deinit(){
return(0);
}

 

  

avatar
Moderator
3419
GumRai 2016.01.15 22:14 #
 

in your indicator, replace

while(pos-1>0)

with

while(pos>=0)

 

You are giving the same value to historical bars when starting the indicator

Did you intend this?

int start(){

int count = IndicatorCounted();
int pos = Bars - count;

while(pos>=0)
   {
      var_a[pos]=iMACD(NULL, 0, 8, 17, 9, PRICE_CLOSE, MODE_SIGNAL, pos);
      var_b[pos]=iMACD(NULL, 0, 8, 17, 9, PRICE_CLOSE, MODE_MAIN, pos);
        pos--; 
}

return (0);
}

 .

avatar
119
Doerk 2016.01.16 19:33 #
 

Hey there,

where is Maintrend_TimeFrame coming from? And when does it return 0, during backtest, live or when added in backtest to another EA? When added to strategy tester while you testing another EA, it cannot work, because the tester does not support other timeframes int such case, just btw. 

Doerk 

avatar
9
pacman992 2016.01.17 15:40 #
 
GumRai:

in your indicator, replace

with

 

You are giving the same value to historical bars when starting the indicator

Did you intend this?

 .

thanks for the tip, but what i want to know is the parameter index at iCustom call
avatar
13006
Back to topics list  

To add comments, please log in or register