Any rookie question, so as not to clutter up the forum. Professionals, don't pass by. Nowhere without you - 6. - page 873

 
artmedia70:
We simply write functions into .mqh file, connect this file to Expert Advisor #include <file_name.mqh> if in the directory include, or #include "file_name.mqh" if in the folder with the main program (Expert Advisor, indicator, script). That is all. The functions that are in the file will be visible in the Expert Advisor/indicator/script. The main thing is to connect the file before calling any function from the Expert Advisor/indicator/script that is in the file.


Good. So, this EA will work, or something is missing?

//--------------------------------------------------------------------#include "Variables.mqh"                    //Описание переменных #include "CritOpen.mgh"                     //Включаемый файл Критерии открытия ордеров#include "CritClose.mgh"                    //Включаемый файл Критерии закрытия ордеров//--------------------------------------------------------------------int init()                                    {   Variables();                           //Функция Описание переменных    CritOpen();                            //Функция Критерии открытия ордеров    CritClose();                           //Функция Критерии закрытия ордеров    return;   }        int start()                                               {            if (Orders==0)                //Если нет откытых или отложенных ордеров             {             CritOpen();                                               }               else                  {                  CritClose();                              }       return;         }//----------------------------конец кода?--------------------------

What the hell - outputs the SRC in one line. I will repeat it by simple copying

 
artmedia70:
We simply write functions into .mqh file, connect this file to the Expert Advisor #include <file_name.mqh> if in the directory include, or #include "file_name.mqh" if in the folder with the main program (Expert Advisor, indicator, script). That is all. The functions that are in the file will be visible in the Expert Advisor/indicator/script. The main thing is to connect the file before calling any function from the Expert Advisor/indicator/script that is in the file.

repetition:

//--------------------------------------------------------------------
#include "Variables.mqh" //Variables description
#include "CritOpen.
mgh" //Include "CritOpen.mgh" //include "Criteria for closing orders
//--------------------------------------------------------------------
int init()
{
Variables();//Function Variables Description
CritOpen(); //Function Criteria for opening of orders
CritClose();//Function Criteria for closing orders
return;
}
int start()
{
if (Orders==0) //If there are no open or pending orders
{
CritOpen();
}
else
{
CritClose();
}
return;
}
//---------------------------- end of code?--------------------------

Will it work?

 

Gentlemen, will the Expert Advisor described above work, or is there something else that must be included, and I have missed it?

Or, for example, I have doubts about correctness of initialization of included files - is init() function described correctly?

Thanks.

 
rapid_minus:

Gentlemen, will the Expert Advisor described above work, or is there something else that must be included, and I have missed it?

Or, for example, I have doubts about correctness of initialization of included files - is init() function described correctly?

Thanks.

It will be. You can write all functions in one inclusion, it will also work. You can leave the .mq4 extension and call it the same way, it will work just as well.

 
Help me retrieve the maximum value of an indicator in an EA. I have an indicator that calculates the maximal value through the array without any problems, but now I'm not sure how to pass it to the EA or to transfer the code of the indicator to the EA or something else ... in general, I'm stumped. :(
 
evillive:

It will. You can write all functions in one inclusion, it will also work. You can leave the .mq4 extension and call it the same way, it will work just as well.

Thank you! You have reassured me. I will now try to test it using the current year. (God bless!)
 

Oops! Something is missing. Says in the log that it can't load my EA and can't open the.ex4 file.

General error [2] .What does this mean?

 
rapid_minus:

Oops! Something is missing. Says in the log that it can't load my EA and can't open the .ex4 file.

General error [2] .What does this mean?

Has it compiled?
 
Alexandr24:
Help me retrieve the maximum value of an indicator in an EA. I have an indicator that calculates the maximal value through the array without any problems, but now I'm not sure how to pass it to the EA or to transfer the code of the indicator to the EA or something else ... in general, I'm stumped. :(
If you want to use a buffer for this value and read it from the EA, that would be the easiest way.
 
evillive:
Did it compile?
I compiled (or rather pressed the "Compile" button) both it and all the include files. But how to know if they compiled is the question.
Reason: