question to MetaQuotes - OnTrade vs OnTradeTransaction

 

Dear MetaQuotes,

Since you have just introduced new event handling function OnTradeTransaction(), could you please clarify - does this function completely enhance the old OnTrade() function? What I mean is - is there a point in using OnTrade() any longer when writing EAs from scratch? (e.g. if OnTrade() is kept only as a legacy function to support "old" EAs).

 
Both functions are "legal" for using in EA. You can use the one you want, we are not planning to remove any function from MQL5.
 
Rosh:

Both functions are "legal" for using in EA. You can use the one you want, we are not planning to remove any function from MQL5.
Thanks Rosh. So if I decide to use OnTradeTransaction, I do not lose any functionality of OnTrade, just gain some extra functionality?
 

Certainly, don't worry.
 
Rosh:

Certainly, don't worry.
Thanks, good to now. By the way, it's great that you managed to implement it before ATC2012 :)
 

Hello, 

This function does not trigger at all where OnTrade does, in other words I does not work in my environment,  any piece of code that works would be greatly appreciated.

 

this does not work:

void  OnTradeTransaction(

   MqlTradeTransaction&    trans,        // trade transaction structure

   MqlTradeRequest&        request,      // request structure

   MqlTradeResult&         result        // result structure

   )

{

  Print("OnTradeTransactio ");

Documentation on MQL5: Standard Constants, Enumerations and Structures / Data Structures / Structure of a Trade Transaction
  • www.mql5.com
Standard Constants, Enumerations and Structures / Data Structures / Structure of a Trade Transaction - Documentation on MQL5
 
galafron:

Hello, 

This function does not trigger at all where OnTrade does, in other words I does not work in my environment,  any piece of code that works would be greatly appreciated.

 

this does not work:

void  OnTradeTransaction(

   MqlTradeTransaction&    trans,        // trade transaction structure

   MqlTradeRequest&        request,      // request structure

   MqlTradeResult&         result        // result structure

   )

{

  Print("OnTradeTransactio ");

 

Hi dear

you should use following syntax for defining this event

void  OnTradeTransaction(

   const MqlTradeTransaction&    trans,        // trade transaction structure

   const MqlTradeRequest&        request,      // request structure

   const MqlTradeResult&         result        // result structure

   )

{

  Print("OnTradeTransactio ");

}

 
hnp2500:

Hi dear

you should use following syntax for defining this event

void  OnTradeTransaction(

   const MqlTradeTransaction&    trans,        // trade transaction structure

   const MqlTradeRequest&        request,      // request structure

   const MqlTradeResult&         result        // result structure

   )

{

  Print("OnTradeTransactio ");

}

@hnp2500, why you bumping  up old topic just to copy paste ?
 
phi.nuts:
@hnp2500, why you bumping  up old topic just to copy paste ?

I am in wonder of your comment!

it is not copy paste!!

if you pay attention syntax has difference.

I had same problem some minutes ago and i found solution for it.

I search for solution in web and finally I found mentioned solution

you should add const to input parameters of OnTradeTransaction event to work.

previous one: MqlTradeTransaction&    trans

new one: const MqlTradeTransaction&    trans

adding const will resolve issue

!!!

 
hnp2500:

I am in wonder of your comment!

it is not copy paste!!

if you pay attention syntax has difference.

I had same problem some minutes ago and i found solution for it.

I search for solution in web and finally I found mentioned solution

you should add const to input parameters of OnTradeTransaction event to work.

previous one: MqlTradeTransaction&    trans

new one: const MqlTradeTransaction&    trans

adding const will resolve issue

!!!


You're right !. Sorry for my bad.

Next time please use SRC button to post the code, coz it will make lot of easier to read the code, and do explain what's the differences  (add const), so rookie like me will never confuse again ;)

 

void  OnTradeTransaction(
    const MqlTradeTransaction&    trans,        // trade transaction structure
    const MqlTradeRequest&          request,      // request structure
    const MqlTradeResult&           result        // result structure
    )

  {
  Print("OnTradeTransactio ");
  }

 

 

 
phi.nuts:

You're right !. Sorry for my bad.

Next time please use SRC button to post the code, coz it will make lot of easier to read the code, and do explain what's the differences  (add const), so rookie like me will never confuse again ;)

 

 

 

OK, sure

thanks for your guidance