Strange value of calculated lot

 

Hello there,

I have the following formula:

int tp=50;
double lot = (8 /tp)/(SymbolInfoDouble(Symbol(), SYMBOL_TRADE_TICK_VALUE)); 
// fyi SymbolInfoDouble(Symbol(), SYMBOL_TRADE_TICK_VALUE) =1

When I print the value of lot is always 0.


I don't understand why...


Thanks,

 
Iulian Astalus:

Hello there,

I have the following formula:

When I print the value of lot is always 0.


I don't understand why...


Thanks,

Put a decimal point after the 8.
double lot = (8. /tp)/(SymbolInfoDouble(Symbol(), SYMBOL_TRADE_TICK_VALUE));

By the way, you probably want to take into account the tick size when doing LOT calculations.

https://www.mql5.com/en/forum/126450/page9#comment_3278417