I'm trying to detect an order opened by my EA and closed manually.
I tried with magic number but, unfortunately, get only 0 for manually closed orders.
Anyone know how to reliable detect an order opened by an EA and closed manually ?
Magic number 0 means that the order was closed manually.
You can monitor OrdersTotal() for increase and decrease in orders.
Thank @marco @fxsaber
What i'm trying to do is to count the monthly/weekly profit for a given pair. Sometimes when price goes against trend I close my position manually and I realized that my code doesnt manage orders closed manually.
After trying many things I think I have to loop on positions and not on deals because positions keeps the magic number info like MT4.
So my next steps are:
Do you think it's the good way to achieve it ?
I ask because it's what I tried but I think I do something wrong when handle the array
Finally I did it and after I successeded I found your library https://www.mql5.com/en/code/16006
You did a great job
Please enable the necessary setting in your browser, otherwise you will not be able to log in.