I’ve read this post. But I am still not clear.
Here is my log when stop loss is executed in strategy tester.
Now I have a position.
It looks like OnTradeTransaction() is triggered 3 times.
The MqlTradeTransaction is: TRADE_TRANSACTION_HISTORY_ADD
The MqlTradeTransaction is: TRADE_TRANSACTION_ORDER_DELETE
The MqlTradeTransaction is: TRADE_TRANSACTION_DEAL_ADD
position is closed.
There is no transaction type called “stop_loss_executed”. The right way to detect stop loss transaction is to do what?
My idea is if a position is closed, then it can be result from a stop loss on a position, or user manually send an order. There is no way to tell the difference. Is this correct?
If I am wrong, please tell me how to detect a stop loss event.
Here is my log for that minute when stop loss event is triggered.
onTradeTransaction.txt 10 KB