Calling CExpert TradeEvent Functions

 

Hi, I'm trying to reimplement this class 

//+------------------------------------------------------------------+
//| Includes                                                         |
//+------------------------------------------------------------------+
#include <Expert\Expert.mqh>

//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
class CExpertFMa : public CExpert
  {
private:
protected:
   //--- trade events
   virtual bool      TradeEventPositionStopTake(void)       { Print(__FUNCTION__); return(true); }
   virtual bool      TradeEventOrderTriggered(void)         { Print(__FUNCTION__); return(true); }
   virtual bool      TradeEventPositionOpened(void)         { Print(__FUNCTION__); return(true); }
   virtual bool      TradeEventPositionVolumeChanged(void)  { Print(__FUNCTION__); return(true); }
   virtual bool      TradeEventPositionModified(void)       { Print(__FUNCTION__); return(true); }
   virtual bool      TradeEventPositionClosed(void)         { Print(__FUNCTION__); return(true); }
   virtual bool      TradeEventOrderPlaced(void)            { Print(__FUNCTION__); return(true); }
   virtual bool      TradeEventOrderModified(void)          { Print(__FUNCTION__); return(true); }
   virtual bool      TradeEventOrderDeleted(void)           { Print(__FUNCTION__); return(true); }
   virtual bool      TradeEventNotIdentified(void)          { Print(__FUNCTION__); return(true); }
public:
                     CExpertFMa();
                    ~CExpertFMa();
   bool              Position() { return SelectPosition(); };
  };
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
CExpertFMa::CExpertFMa()
  {
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
CExpertFMa::~CExpertFMa()
  {
  }
//+------------------------------------------------------------------+

But only function CExpertFMa::TradeEventNotIdentified (called from void CExpert::OnTrade(void)) is called. Can anyone help me with this?

Thank you.

 
Felipe Augusto Torres Maggico :

Hi, I'm trying to reimplement this class 

But only function  CExpertFMa::TradeEventNotIdentified (called from void CExpert::OnTrade(void)) is called. Can anyone help me with this?

Thank you.

Generate Expert Advisors with Wizard MQL. Write your trading modules (trading signals module, money management module ...). But like this - you will not get through.

 

Found it:

OnTradeProcess(true);

Thank you.

 
Setting the trade process true only calls TradeEventPositionStopTake(). Any ideas?
 

WaitEvent() needs to be called.

Thank you.

 
Felipe Augusto Torres Maggico:

WaitEvent() needs to be called.

Thank you.

Thanks Felipe, I was looking for this. I have a question about this. How i can to execute any code into CSignal module when any of these trade events is triggered?

 

Just populate the function you want to execute some code (I hope that I understood you question).

E.g.:

virtual bool      TradeEventPositionStopTake(void)
{
Print(__FUNCTION__);
// do something
return(true);
}
 
Felipe Augusto Torres Maggico:

Just populate the function you want to execute some code (I hope that I understood you question).

E.g.:

but ... into CSignal module is possible? i need to update the signal when trade is executed and when trade is closed. how i can to do this, do you know?

 
Antonio Jesus Martin Ruiz:

but ... into CSignal module is possible?

When you create a CExpertSignal using the Wizard, a CExpert instance is also created. Just change it to the CExpertFMa class.

 
Felipe Augusto Torres Maggico:

When you create a CExpertSignal using the Wizard, a CExpert instance is also created. Just change it to the CExpertFMa class.

ok, i will try it. thanks so much.

 
Felipe Augusto Torres Maggico:

WaitEvent() needs to be called.

Thank you.

Felipe, hello again. Where WaitEvent(EVENT) function has to be called? In to OnTick function?

Reason: