Odd warning using iADX in an EA

 
Hi,



I'm working on my first complete EA and when compiling I get the following warning:

implicit conversion from 'number' to 'string'  

The line it refers to is:


ADXmain = iADX(0,0,14,PRICE_CLOSE,MODE_MAIN,1);


where ADXMain is declared as a double. According to the help file iADX is type double so I don't understand why MetaEditor wants to convert it to a string. Can anyone tell me what I'm doing wrong?



Thanks.
 
Need more code.
 
Marco vd Heijden:
Need more code.
OK. Here is the function:



void OrderCheckBeginn ()
{
   double ADXmain,ADXplus,ADXminus;
   double ADXmain_old;
   double rsi_1 = iRSI(Symbol(), PERIOD_CURRENT, periodRSI, PRICE_CLOSE, 1);

//---- get indicators
   ADXmain = iADX(0,0,14,0,0,1);
   ADXplus = iADX(0,0,14,0,1,1);
   ADXminus = iADX(0,0,14,0,2,1);
   ADXmain_old = iADX(0,0,14,0,0,2);

  
//---- sell conditions


   if( (ADXplus<ADXminus) && (rsi_1 > RSI_Sell) && (ADXmain>=25) && (ADXmain>ADXmain_old))


all of the iADX lines are egtting the same warning. BTW I just changed the notation from text to numbers thinking I might have misspelled something.
 
The code is correct. Perhaps the error is on other line that correlated with ADXmain.
 

I can compile this

double ADXmain = iADX(0,0,14,PRICE_CLOSE,MODE_MAIN,1);

Without errors.

Are there any includes?

 
Irwan Adnan:
The code is correct. Perhaps the error is on other line that correlated with ADXmain.
There are no other lines that use it and the function is global. Since I'm only about 50% finished I can't test it yet. Should I expect wrong behavior with this warning or can I ignore it?
 
datas_brother:
OK. Here is the function:



void OrderCheckBeginn ()

Try to change function type as double not void.

 
Irwan Adnan:

Try to change function type as double not void.

Thanks for the help. I just tried that but it didn't work.

I've been trying to find the error now for 4 days now, looking at the help file one more time I found it! It works when I change it to:

   ADXmain = iADX(NULL,0,14,0,0,1);

"NULL" instead of "0".



Again Proof that the hardest problems to find are the ones you cause yourself.
 
datas_brother:
Thanks for the help. I just tried that but it didn't work.

I've been trying to find the error now for 4 days now, looking at the help file one more time I found it! It works when I change it to:

   ADXmain = iADX(NULL,0,14,0,0,1);

"NULL" instead of "0".



Again Proof that the hardest problems to find are the ones you cause yourself.

But it is still incorrect.

The reason it warned you about implicit conversion from number to string is that the first position is a string and its the symbolname.

double  iADX(
   string       symbol,        // symbol
   int          timeframe,     // timeframe
   int          period,        // averaging period
   int          applied_price, // applied price
   int          mode,          // line index
   int          shift          // shift
   );

You should use

double ADXmain=iADX(Symbol(),.....
To match the chart symbol to the indicator call or use a string value like "EURUSD" instead.
 
Marco vd Heijden:

But it is still incorrect.

The reason it warned you about implicit conversion from number to string is that the first position is a string and its the symbolname.

double  iADX(
   string       symbol,        // symbol
   int          timeframe,     // timeframe
   int          period,        // averaging period
   int          applied_price, // applied price
   int          mode,          // line index
   int          shift          // shift
   );

You should use

double ADXmain=iADX(Symbol(),.....
To match the chart symbol to the indicator call or use a string value like "EURUSD" instead.
Yes but acc. to help "NULL" means current symbol. After changing, the warnings went away.