Resolve warnings

 

How do I resolve the warning on this code line 

return NormalizeDouble(basePrice + (double)steps * stepPips * multiplier, MarketInfo(Symbol(), MODE_DIGITS));

Compilation warning

possible loss of data due to type conversion Meta EA.mq4 47 79

your help will be appreciated 

Improperly formatted code edited by moderator. Please use the CODE button (Alt-S) when inserting code.

Code button in editor

 
Your topic has been moved to the section: MQL4 and MetaTrader 4
Please consider which section is most appropriate — https://www.mql5.com/en/forum/172166/page6#comment_49114893
 
return NormalizeDouble(basePrice + (double)steps * stepPips * multiplier, (int)MarketInfo(Symbol(), MODE_DIGITS));

But for the current symbol you don't need MarketInfo:

return NormalizeDouble(basePrice + (double)steps * stepPips * multiplier, Digits());
 
Yaw Owusu Ampong: How do I resolve the warning on this code line . Compilation warning. your help will be appreciated

The function MarketInfo() returns a "double" data-type, but the 2nd parameter of NormaliseDouble() expects an "int" data-type.

Since it is an implicit typecasting, it warns you of the situation, so use an explicit type-casting to resolve the issue:

return NormalizeDouble( basePrice + (double) steps * stepPips * multiplier, (int) MarketInfo( Symbol(), MODE_DIGITS ) );
 
Vladislav Boyko #:

But for the current symbol you don't need MarketInfo:

Thanks Boyko, your suggestion worked, next time will let you code for me

 
Be aware that normalizing prices to Digits can lead to invalid prices. The right way is to normalize to tick size.

Same for lots, you don't need to normalize to 2 decimal digits, but to lot step.