find attached a simple EA which demonstrates the problem. The EA opens long along with stop and target then short, then long and so on.
A dump method is also contained. Just apply EUR.USD 1 minute 1 week and watch the transaction dumps in backtest log.
Thank you for help.
Here your stoploss is triggered :
2013.05.07 18:45:27 Core 1 2013.05.03 18:35:40 trans=symbol=EURUSD price=1.3104000 volume=0.01 sl=0.0000000 tp=0.0000000 order=107 deal=107 entry-type=IN trans-type=DEAL_ADD order_type=BUY deal_type=DEAL_TYPE_SELL type_time=0 expiration=1970.01.01 00:00 price_trigger=0.0000000 profit
but this is entry-type=IN , not out....
You are right, on the other hand, how can i know that i can rely on sl=0.0 and tp=0.0 means this is stop or target order and not: sl and tp simply missed (in the transaction structure)..?
A structure can't have missing field. This is transaction about a deal (DEAL_TYPE_SELL), a deal can't have a SL/TP, that make no sense. A SL (or TP) is an order (a sort of special pending order), when it is triggered, the order result in a deal. You can check all of that within OnTradeTransaction.
Yes, was a help. What do mean byconfusing? I wondered about getting always ENTRY_IN. You said never believe on what program tells me. I say, you are right, so sl=0.0 or tp=0.0 (missed values) could also a mistake by server - forgot to wroite values.
What is important for me: a save method to determine what transaction is stop out. MT is great but in many aspects, confusing, not doing what you normally would expect, like in this case.
Do you know what i mean ?
I checked. When a SL/TP is triggered you have these transaction :
a position not related to a deal execution. This type of transaction
shows that a position has been changed on a trade server side. Position
volume, open price, Stop Loss and Take Profit levels can be changed.
Data on changes are submitted in MqlTradeTransaction
structure via OnTradeTransaction handler. Position change (adding,
changing or closing), as a result of a deal execution, does not lead to
the occurrence of TRADE_TRANSACTION_POSITION transaction.