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.
Certainly, don't worry.
Certainly, don't worry.
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 ");
}
- www.mql5.com
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 ");
}
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 ?
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
!!!
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 "); }
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

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
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).