In my EA I open a position with both tp and sl.
When the position closes, I want to know if it was due to the tp or the sl.
What code can do this?
Thanks for the reply angevoyageur
So, using a long as an example, do you mean to check the history to see if close price was above tp, then tp was used and if close price was below sl, then sl was used?
I thought of this, but didn't think this logic was solid because the price can spike past the sl/tp threshold and go below again. I.e. the sl/tp could have been used but price changed by the time position closed, right?
But if this is the only way to check, then I don't have a choice.
Any other thoughts?