Download MetaTrader 5
To add comments, please log in or register
Develop trading robots to order. Make profit with Freelance service!
BartWinter
58
BartWinter 2015.06.09 19:31 

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.
   }
 }

Alain Verleyen
Moderator
28651
Alain Verleyen 2015.06.09 21:57  

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.


Alain Verleyen
Moderator
28651
Alain Verleyen 2015.06.09 21:59  
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.
BartWinter
58
BartWinter 2015.06.09 22:08  
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 :)
/
To add comments, please log in or register