How to get Contract size? - page 3

 
Hello there, hope this works out for you.

int contractSize( string symbol )
{
     double cSize = SymbolInfoDouble(symbol, SYMBOL_TRADE_CONTRACT_SIZE);
     int trade_unit = (int)cSize;
     return trade_unit;
}

You can call by preference below:
contractSize(_Symbol);
contractSize("EURUSD");
 
Malcolm Okechukwu:
Hello there, hope this works out for you.

int contractSize( string symbol )
{
     double cSize = SymbolInfoDouble(symbol, SYMBOL_TRADE_CONTRACT_SIZE);
     int trade_unit = (int)cSize;
     return trade_unit;
}

You can call by preference below:
contractSize(_Symbol);
contractSize(EURUSD);

Please don't bring up 6 year old topics for no good reason. Especially when the answer had been given in the post before yours.

I don't know that SymbolInfoDouble was part of MQL4 when this thread was started.

 
Keith Watford:

Please don't bring up 6 year old topics for no good reason. Especially when the answer had been given in the post before yours.

I don't know that SymbolInfoDouble was part of MQL4 when this thread was started.

Well, so sorry about that there, new users come in everyday with their worries and it depends on which answer catches the eye of the seeker. Moreover, don't you think 6 years is enough for an answer to be deprecated?
 
Malcolm Okechukwu:
Well, so sorry about that there, new users come in everyday with their worries and it depends on which answer catches the eye of the seeker. Moreover, don't you think 6 years is enough for an answer to be deprecated?

What you don't seem to understand is that new users may not even realise it is an old thread and that it may include posts that are way out of date. They may think that they are learning new stuff whereas they are actually learning old stuff that is no longer relevant.

 
  1. Don't resurrect old threads without a very good reason. A lot has changed since Build 600 and Higher. 2014.02.03
  2. SymbolInfoDouble didn't exist before that.

  3. Please edit your (original) post and use the CODE button (Alt-S)! (For large amounts of code, attach it.)
              General rules and best pratices of the Forum. - General - MQL5 programming forum
              Messages Editor

 
Malcolm Okechukwu:
Hello there, hope this works out for you.

int contractSize( string symbol )
{
     double cSize = SymbolInfoDouble(symbol, SYMBOL_TRADE_CONTRACT_SIZE);
     int trade_unit = (int)cSize;
     return trade_unit;
}

You can call by preference below:
contractSize(_Symbol);
contractSize("EURUSD");

Actually the same answer was given in reply #20, which is 6 years old.

So, there is nothing new added here.

Reason: