Download MetaTrader 5

Include Files

To add comments, please log in or register
Have you developed an application? Publish it in Code Base!
Ernest Klokow
1084
Ernest Klokow 2014.11.11 17:30 

I just want to clear something up about .mqh Include files.

Once I have compiled an EA that uses an Include .mqh file do I still have to distribute this .mqh file to all computers and MT4 's that use this EA or does the code of the EA now include the code of the .mqh files after compilation.

If the answer is Yes I still have to distribute the .mqh file and install it in the Include folder of all computers and MT4's how can I rather insert that code into the actual EA?

Will appreciate any help!

Carl Schreiber
6580
Carl Schreiber 2014.11.11 20:20  

Well you can check it out yourself very easily: Compile the EA, rename the my.mqh and try to apply the EA - doe ist run?

If so it will run elsewhere too.

whroeder1
14470
whroeder1 2014.11.11 22:28  
ernest02: does the code of the EA now include the code of the .mqh files after compilation.

Compiling doesn't change your code. Period. It didn't include it before, it doesn't include it after.

Compiling creates your executable. Period. The executable has nothing to do with your code.

Ernest Klokow
1084
Ernest Klokow 2014.11.12 06:45  

Thank you for your assistance.

I would like to incorporate the code of the .mqh file rather into the main code of my EA. I have tried but get errors like "function can only be declared in global scope". Can you help me?

Here is the code in the .mqh file

double PipPoint(string Currency)
        {
                int CalcDigits = MarketInfo(Currency,MODE_DIGITS);
                if(CalcDigits == 2 || CalcDigits == 3) double CalcPoint = 0.01;
                else if(CalcDigits == 4 || CalcDigits == 5) CalcPoint = 0.0001;
                return(CalcPoint);
        }


int GetSlippage(string Currency, int SlippagePips)
        {
                int CalcDigits = MarketInfo(Currency,MODE_DIGITS);
                if(CalcDigits == 2 || CalcDigits == 4) double CalcSlippage = SlippagePips;
                else if(CalcDigits == 3 || CalcDigits == 5) CalcSlippage = SlippagePips * 10;
                return(CalcSlippage);
        }

and here is part of the code in my EA that uses that code:

int init()


        {
                UsePoint = PipPoint(Symbol());
                UseSlippage = GetSlippage(Symbol(),Slippage);
           
   }
SYED NAUFAL GADDAFI
1401
SYED NAUFAL GADDAFI 2014.11.12 07:01  
I have tried but get errors like "function can only be declared in global scope". Can you help me?
The function must be put before or after init() not inside it.
Ernest Klokow
1084
Ernest Klokow 2014.11.12 07:13  
I put the functions in the start() area but get the same message.
SYED NAUFAL GADDAFI
1401
SYED NAUFAL GADDAFI 2014.11.12 07:19  
ernest02:
I put the functions in the start() area but get the same message.

Function cannot be put inside the start() also.


To be honest, your problem is an easy fix but just need to double check. I usually do like that.

Ernest Klokow
1084
Ernest Klokow 2014.11.12 07:27  
If I cannot put the functions in either the init() or start() areas, where do I put it?
SYED NAUFAL GADDAFI
1401
SYED NAUFAL GADDAFI 2014.11.12 07:37  
Just put it outside. Before or after, doesn't matter.
Carl Schreiber
6580
Carl Schreiber 2014.11.12 13:20  
ernest02:

Thank you for your assistance.

I would like to incorporate the code of the .mqh file rather into the main code of my EA. I have tried but get errors like "function can only be declared in global scope". Can you help me?

Here is the code in the .mqh file

and here is part of the code in my EA that uses that code:

May be what you are looking for is 1) a compiled .mqh, that export(s) its (some) functions  2) one (several) EA(s) that import(s) the functions it needs.

Look in your reference of export in the index-tap search-field.

whroeder1
14470
whroeder1 2014.11.12 17:34  
ernest02: If I cannot put the functions in either the init() or start() areas, where do I put it?
What part of
"function can only be declared in global scope"
was unclear? Global scope is outside of every function.
12
To add comments, please log in or register