Download MetaTrader 5

mqh file

To add comments, please log in or register
Alberto Tortella
586
Alberto Tortella  

Hi all, is there the possibility to shift a portion of code in an .mqh file, in order to obtain a smaller .mq4 file?

I'd like to shift in a .mqh file the part code in which I create the Global Variables, but I don't want to create a single .mqh file for every Global Variable (using the return function).

Thank you!

Ralf Graf
1977
Ralf Graf  
Alberto Tortella:

Hi all, is there the possibility to shift a portion of code in an .mqh file, in order to obtain a smaller .mq4 file?

I'd like to shift in a .mqh file the part code in which I create the Global Variables, but I don't want to create a single .mqh file for every Global Variable (using the return function).

Thank you!

Sure.

Just include the mqh-file in your mq4.

That's it

Anthony Garot
397
Anthony Garot  
Alberto Tortella:

Hi all, is there the possibility to shift a portion of code in an .mqh file, in order to obtain a smaller .mq4 file?

I'd like to shift in a .mqh file the part code in which I create the Global Variables, but I don't want to create a single .mqh file for every Global Variable (using the return function).

Thank you!

Typically you want to put declarations in the header files and code in the implementation files.

Consider (for C++)

https://stackoverflow.com/questions/583255/c-code-in-header-files

nicholishen
1519
nicholishen  
Anthony Garot:

Typically you want to put declarations in the header files and code in the implementation files.

Consider (for C++)

https://stackoverflow.com/questions/583255/c-code-in-header-files


Except with MQL:

something_h.mqh

class Something : public CObject
{
   public: void PublicMethod();
};

#include "../src/something_src.mqh" //don't have to do this with C++

something_src.mqh

//Something src
#include "../include/something_h.mqh"

void Something::PublicMethod()
{
   Print("Hello world!");
}

program.mq4

#include "include/something_h.mqh"

Something *something = new Something;
To add comments, please log in or register