Processing of trade events in Expert Advisor using the OnTrade() function
- 2010.07.22
- KlimMalgin
- www.mql5.com
MQL5 gave a mass of innovations, including work with events of various types (timer events, trade events, custom events, etc.). Ability to handle events allows you to create completely new type of programs for automatic and semi-automatic trading. In this article we will consider trade events and write some code for the OnTrade() function, that will process the Trade event.
That was the best link!! Thank you!

You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Hello All,
I'm working on a project that would allow me to take all of my clients data and put it to a web server (mySQL). Now Ironically enough, it was easier to figure out sending this to a mysql server than just trying to figure which event to use.
I would have to say thanks for this article (http://mqlmagazine.com/mql-programming/mql5-connecting-to-mysql/)
now If I could just get a hand with finding the right event.
Maybe explaining the scenario would help.
So my client opens up the trader, excepts dlls for the EA, and starts to trade... as soon as a "close trade" happens, I would like to fire off to my DB the info from that trade (date/price in, date/price out, ect...)
I think this would give me a close to "live" update as possible.
So when in the world does that Event happen?
So the closest thing that i found is mql5's OnTrade()
but it fires off a couple of events and I don't know how to filter them
such as:performed pending, order opening, position opening/closing, stops setting, pending order triggering
//----
void OnTrade()
{
bool is_closed = TRUE;
if(is_closed == "THIS IS WHAT I'm after, something that says that this event is closed"){
do_mySQL_function();
}
}
------//
Is OnTrade() even the right direction... is there something else? I really hope that all of this makes sense to someone :) and that this forum will hold the answer, because lets face it...not too many people are into mq5
Thanks,
Dustin