How to find if a trade hit SL or TP? - page 2

 
angevoyageur:

Just for information, there is now the OnTrade() event : https://forum.mql4.com/61012



Thanks, but I have been unable to find OnTrade anywhere in the documentation. Maybe reference to it has been removed in the later updates?.

I think that I will check as Thirteen said

For buy trades:

  • if the OrderClosePrice() is equal to or greater than the OrderTakeProfit(), the trade hit the TP.

but if OrderClosePrice() is lower than the OrderTakeProfit(), use the OrderCloseTime to check that price had, at around that time equalled or exceeded the TP

 
deysmacro:

And here I thought that you are talking about SL/TP settings which broker will honor or not.




I don't know where you got that impression. This was only ever about an EA being about to determine whether a trade was closed by hitting TP or SL with total accuracy.
 
GumRai:


Thanks, but I have been unable to find OnTrade anywhere in the documentation. Maybe reference to it has been removed in the later updates?.

I think that I will check as Thirteen said

For buy trades:

  • if the OrderClosePrice() is equal to or greater than the OrderTakeProfit(), the trade hit the TP.

but if OrderClosePrice() is lower than the OrderTakeProfit(), use the OrderCloseTime to check that price had, at around that time equalled or exceeded the TP

Right, sorry, I didn't check.
 
GumRai:

It's a solution, but the problem is when the user closes a trade manually without it actually hitting either SL or TP.
Oh I see, I hadnt realized you meant user intervention. I need to code that into mine too. As it is right now that would cause my EA to see it as a SL/TP trade.
 
So basically we just want to make sure that the closed trades are actually hits SL/TP or not. LOL.. very bad misunderstanding from me.
Reason: