Download MetaTrader 5

Why use "Long" integer type rather than just "int"?

To add comments, please log in or register
Brian Kester
820
Brian Kester  

Hi i am a new programmer. Can someone please give me an answer to why I would use "Long" as integer type rather than "int" when creating ivolume variable?

I speculate the reason is because int type is 4 bytes and Long type is 8 bytes...... but that should not make a difference for Volume. So why?

int

The size of the int type is 4 bytes (32 bits). The minimal value is -2 147 483 648, the maximal one is 2 147 483 647.

long

The size of the long type is 8 bytes (64 bits). The minimum value is -9 223 372 036 854 775 808, the maximum value is 9 223 372 036 854 775 807.

long iVolume(
string symbol, // symbol
int timeframe, // timeframe
int shift // shift
);

Thanks!

whroeder1
15331
whroeder1  
c3po:.. but that should not make a difference for Volume. So why?
Because mqlRates.real_volume is traded volume must be long. iVolume and Volume[] is tick count but could be either.
Brian Kester
820
Brian Kester  

Thanks friend.

So, can use ivolume(EURUSD,0,0) and find the total volume so far for current candle?

To add comments, please log in or register