Hello,
after a number of self-developed Expert advisors I find my way around using the "OnTick" function together with a number of self-programmed functions.
I keep coming across the other events, like for example "on trade" or others.
Even after quite some research, it is not clear for me how I could potentially use them.
But I am hoping that they can make my live easier.
Please can you point me to a place where this is well explained?
and sorry - I have tried the standard documentation but unfortunately it is still not clear.
Thanks a lot in advance!!!
It is called each time a position is opened or closed. For example if you want to check the profit of each closed position right after it got closed and have your EA pause trading as a result of a condition. Or reverse a position.
Hello there,
thanks a lot.
With regards to position/deal/order, yes, thanks, this one is ok for me. It also has taken some time ...
Thanks for the answer, so I understand I can use the OnTrade Event to check what happened right now in a trade.
Are there specific commands to be used at this point in time?
I mean, any other than the History?
Is there any structure which is filled automatically so that I can refer to it in order to find out about this particular trade?
For example, lets assume that a deal was closed because of Stop Loss.
What would be the best way to inquire the information about it, in the moment of "on trade"?
What I have done until today is to do "HistorySelect" using the time, when a particular deal was opened, until the current time,
and then loop through the deals.
But maybe using the "OnTrade" event there is an easier way to do it?
Thanks a lot in advance!
Hello there,
thanks a lot.
With regards to position/deal/order, yes, thanks, this one is ok for me. It also has taken some time ...
Thanks for the answer, so I understand I can use the OnTrade Event to check what happened right now in a trade.
Are there specific commands to be used at this point in time?
I mean, any other than the History?
Is there any structure which is filled automatically so that I can refer to it in order to find out about this particular trade?
For example, lets assume that a deal was closed because of Stop Loss.
What would be the best way to inquire the information about it, in the moment of "on trade"?
What I have done until today is to do "HistorySelect" using the time, when a particular deal was opened, until the current time,
and then loop through the deals.
But maybe using the "OnTrade" event there is an easier way to do it?
Thanks a lot in advance!
I don't think that you have much of a choice, you can either use the functions from functions list or if you look into Trade classes there is this TradeInfo.SomeFunction() or stuff like that but it is basically the same. The data structure where it is all stored IS the History.
Hello and thanks a lot.
In fact I am now able to use the "on trade" event. It already helps me in the sense that I do not have to run my check for every tick, but only when there is a trade, so this is exactly what I wanted.
I have also found a good programming example on how to check last order number from the standard documentation.
So I am happy, question fully answered, thanks a lot.

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hello,
after a number of self-developed Expert advisors I find my way around using the "OnTick" function together with a number of self-programmed functions.
I keep coming across the other events, like for example "on trade" or others.
Even after quite some research, it is not clear for me how I could potentially use them.
But I am hoping that they can make my live easier.
Please can you point me to a place where this is well explained?
and sorry - I have tried the standard documentation but unfortunately it is still not clear.
Thanks a lot in advance!!!