Search code examples
shared-librariesstandardsmql4mql5

Is it Possible to include MQL5 standard library in MQL4 Platform?


I am trying to include MQL5 standard library in my MQL4 developing platform but with no success so far.. I have just copied the include file from MQL5 platform into an include File of an MQL4 Platform but the libraries are not recognized..

not sure where i am going wrong

// 
#include <Trade\PositionInfo.mqh>//|                                                                  |
//+------------------------------------------------------------------+
class Position : public CPositionInfo  
  {
  
CPositionInfo cPositionInfo;

it says CPosition declaration without a type


Solution

  • It is possible to copy the sources of Include from MQL5 folder to MQL4, it compiles ok quite often but it may require you some efforts if you apply MQL5/Include/Math library and some others. There are two libraries that you cannot include into MQL4. They are MQL5\Include\Trade and \OpenCL. The latter is not supported in MQL4, the first one is very different in MQL4. You are trying to extend from Include\Trade\PositionInfo.mqh that is part of Trade library. If you go through that file, you will see it cannot be compiled at MQL4 editor because some functions and constants are not declared.