Expert calling other expert

 

Hi everybody,

I would like to know if it is possible to call an expert inside of another expert.

 
rodrigosm:

I would like to know if it is possible to call an expert inside of another expert.

What do u mean by "call"? An expert is not a function...
 

What I wanna do is write a expert for each type of market movement, like trending market, flat, etc.

With these experts built, I wanna build another expert that decides what type of market is running at that time. This "master" expert will "call" (turn on) the trend expert for example, and turn off all the others.

Just want to have my code clean. I can perfectly write all in one expert, but i would like to do this like calling DLLs.

 
rodrigosm:

What I wanna do is write a expert for each type of market movement, like trending market, flat, etc.

With these experts built, I wanna build another expert that decides what type of market is running at that time. This "master" expert will "call" (turn on) the trend expert for example, and turn off all the others.

Just want to have my code clean. I can perfectly write all in one expert, but i would like to do this like calling DLLs.

How will that achieve 'clean code'? Sounds like trouble to me... If u want their code to be physically separate, then write each one's code in a separate file (and #include it to the main file)...
 
gordon:
How will that achieve 'clean code'? Sounds like trouble to me... If u want their code to be physically separate, then write each one's code in a separate file (and #include it to the main file)...


Thanks gordon. #include is what I was looking for.

I wrote a simple expert using #include, but I'm not geeting any response. Do you have any idea of what am I doing wrong?

Here's the code

expert:

#include <test.mqh>

//+------------------------------------------------------------------+
//| expert initialization function                                   |
//+------------------------------------------------------------------+
int init()
  {
//----
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| expert deinitialization function                                 |
//+------------------------------------------------------------------+
int deinit()
  {
//----
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| expert start function                                            |
//+------------------------------------------------------------------+
int start()
  {
//----
   if (chkTest() == true)
   {
   Print("working");
   }
//----
  } 

#include (mqh):

#import "test.ex4"
bool chkTest();

#import

library(test.ex4):

bool chkTest()
{
return (true);

}

Thanks

Rodrigo

 
//#import "test.ex4"
//bool chkTest();
//#import
#include "test.mq4"

include the code into the ea. Don't try to call another EA.

Alternative would be to have one EA leave global variables to be read by another.

 
gordon:
What do u mean by "call"? An expert is not a function...

 

It's a good idea. IPC is one approach. and the most classical socket-based communication is another approach. You can make your EAmonitor the lowe-le vel system events and trigger the trading logic, i.e. technical analysis and call the trading funcitons.  This is my first feeling while reading your post. Hopfully it might be of some usage to you. good luck!

Reason: