Download MetaTrader 5
To add comments, please log in or register
Do you know that MQL5 is an object-oriented language?
niquedegraaff
63
niquedegraaff 2016.04.14 19:04 

The next very simple piece of code...

// Get chart dimensions
int chart_height = ChartGetInteger(0, CHART_HEIGHT_IN_PIXELS, 0);

 .. produces a beautiful compiler warning.. :

possible loss of data due to type conversion Nique - BO5M.mq4 64 22

Is this a bug?
Fernando Carreiro
1526
Fernando Carreiro 2016.04.14 21:08  
ChartGetInteger() returns a "long", not an "int".
niquedegraaff
63
niquedegraaff 2016.04.14 21:32  
Then they need to fix this doc:
Example:
void OnStart()
  {
   int height=ChartGetInteger(0,CHART_HEIGHT_IN_PIXELS,0);
   int width=ChartGetInteger(0,CHART_WIDTH_IN_PIXELS,0);
   Print("CHART_HEIGHT_IN_PIXELS =",height,"pixels");
   Print("CHART_WIDTH_IN_PIXELS =",width,"pixels");
  }
https://docs.mql4.com/chart_operations/chartgetinteger
Fernando Carreiro
1526
Fernando Carreiro 2016.04.14 21:54  
The docs are correct! It is just the example that is outdated for "strict" compilation, although probably still valid for the old style of non-strict compilation.
/
To add comments, please log in or register