Error in my code "possible loss of data due to type conversion"

 

Hello,

When compiling I have the error "possible loss of data due to type conversion" i suspect it is because of the variable type which the price is being stored in. Any help is greatly appreciated.

Here's the code: (by the way I know it doesn't do anything I'm just looking for a solution to the error) 

float candle1open = iOpen(Symbol(),PERIOD_CURRENT,4);
float candle1close = iClose(Symbol(),PERIOD_CURRENT,4);
float candle2 = iClose(Symbol(),PERIOD_CURRENT,3); 
float candle3 = iClose(Symbol(),PERIOD_CURRENT,2);
float candle4open = iOpen(Symbol(),PERIOD_CURRENT,1);
float candle4close = iClose(Symbol(),PERIOD_CURRENT,1);
//The condition for this candle is below.
if(candle1open<candle1close)
 {
  if(candle4close<candle1close && candle1close<candle2 && candle2<candle3 && candle3<candle4open)
   {
    //Here one would put the next step of the code.
   }
 }

 

Forum on trading, automated trading systems and testing trading strategies


Hello,

Please use the SRC button when you post code. Thank you.


This time, I edited it for you.


 
BartWinter:

Hello,

When compiling I have the error "possible loss of data due to type conversion" i suspect it is because of the variable type which the price is being stored in. Any help is greatly appreciated.

Here's the code: (by the way I know it doesn't do anything I'm just looking for a solution to the error) 


That's not an error, that's a warning. iOpen/iClose return a double not a float.

Common Errors in MQL4 Programs and How to Avoid Them
Common Errors in MQL4 Programs and How to Avoid Them
  • 2014.03.25
  • MetaQuotes Software Corp.
  • www.mql5.com
To avoid critical completion of programs, the previous version compiler handled many errors in the runtime environment. For example, division by zero or array out of range are critical errors and usually lead to program crash. The new compiler can detect actual or potential sources of errors and improve code quality. In this article, we discuss possible errors that can be detected during compilation of old programs and see how to fix them.
 
Alain Verleyen:

That's not an error, that's a warning. iOpen/iClose return a double not a float.

Thanks a lot, I'll use the SRC in the future :)
Reason: