Change variables types

 

Hello MQL5 forum,

 I have some conversion warnings on my EA report.

I just was wondering if there's any way of changing the type of a variable:

double Open;
CopyOpen(0,PERIOD_M1,0,10,Open);
int price=Open[0]/_Point; //There's a conversion warning here, it shouldn't right?

 I have that problem and  IntegerToLong and maybe DateToInteger.

Do you have any ideas? 

Thanks in advance

Pabs 

 
kerso4:

Hello MQL5 forum,

 I have some conversion warnings on my EA report.

I just was wondering if there's any way of changing the type of a variable:

 I have that problem and  IntegerToLong and maybe DateToInteger.

Do you have any ideas? 

Thanks in advance

Pabs 

Yes, that warning is valid.

Your'e dividing a double by a double and expecting an integer. That's why you're getting a "conversion warning". Either change the "price" variable to a double or force the division into an integer (not recommended as it will round - hence the warning)

int price=(int)Open[0]/_Point; 


 

 

exactly so you do

double Open;
CopyOpen(0,PERIOD_M1,0,10,Open);
double price=Open[0]/_Point; //There's a conversion warning here, it shouldn't right?


Price usually is a double right.

 
I understand the problem,  but i just wanted to clean out warnings. 

Thank you for the help. 
Reason: