Download MetaTrader 5
To add comments, please log in or register
What is a social trading? Read the article to find that out!
pacman992
30
pacman992 2016.01.15 14: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);
}
Keith Watford
Moderator
7866
Keith Watford 2016.01.15 21: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);
}

 .

Doerk Hilger
1073
Doerk Hilger 2016.01.16 18: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 

pacman992
30
pacman992 2016.01.17 14: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
whroeder1
13593
whroeder1 2016.01.17 20:40  
/
To add comments, please log in or register