1. Stop orders should not be opened when a transaction arrives, but when an order is placed. That is, the required position has appeared in the position list.
2. When placing a stop order, we should first make sure that there are no stop orders at all.
I have not yet understood why two identical (are they the same?) transactions appear. We have to look at all the parameters of incoming transactions, not only their type.
Let us give us your code example - opening of a position and OnTradeTransaction. This will help us sort things out faster
1. Stop orders should not be opened when a transaction arrives, but when an order is placed. That is, the required position has appeared in the position list.
2. When placing a stop order, we should first make sure that there are no stop orders at all.
I have not yet understood why two identical (are they the same?) transactions appear. We have to look at all the parameters of incoming transactions, not only their type.
Let us give us your code example - opening of a position and OnTradeTransaction. This will help us sort things out faster
1. If stop orders are opened upon position opening, the stop order may trigger first, and not the "main" one.
2. Yes, that is my problem, that is how I will solve it, if what I have described is not an error.
This will be a long example. Let me send you an EA in SD.
You run the risk of not getting out of OnTradeTransaction processing for a very long time - just processed, and the next transaction you just spawned is coming up
And while we're on the subject. Next question. According to the logs, we can see that the order initiating the trade is of sell limit type. But when we get the order type from the OnTradeTransaction() function, we get ORDER_TYPE_BUY. How so? Yes, if we look further, any initiating order in the tester, when processed in OnTradeTransaction, is ORDER_TYPE_BUY. There is definitely an error.
Yes, usually there is one such transaction per trade (whether an order is triggered or a position is closed). But, here I saw two.
Again, the transactions could not have been queued up, as the trade is not high-frequency.
Just in case, a piece with a previous trade(closing a position) + deletion of two orders:
You have an error in logic.
1. Stop orders should not be opened when a transaction arrives, but when an order is placed. That is, the required position has appeared in the position list.
2. When placing a stop order, we should first make sure that there are no stop orders at all.
I have not yet understood why two identical (are they the same?) transactions appear. We have to look at all the parameters of incoming transactions, not only their type.
Let us give us your code example - opening of a position and OnTradeTransaction. This will help us sort things out faster
You have an error in logic.
1. Stop orders should not be opened when a transaction arrives, but when an order is placed. That is, the required position has appeared in the position list.
2. When placing a stop order, we should first make sure that there are no stop orders at all.
I have not yet understood why two identical (are they the same?) transactions appear. We have to look at all the parameters of incoming transactions, not only their type.
Let us give us your code example - opening of a position and OnTradeTransaction. This will help us sort things out faster
1. If stop orders are opened upon position opening, the stop order may trigger first, and not the "main" one.
2. Yes, that is my problem, that is how I will solve it, if what I have described is not an error.
This will be a long example. Let me send you an EA in SD.
Application#1348574
1. If stop orders are opened when an order is placed, it may not be the "main" order that is triggered first, but the stop order.
How is this possible?
Do you trade from OnTradeTransaction by chance?
2. Yes, this is my problem, this is how I will solve it, if what I have described is not an error.
This will be a long example. Let me send you an EA in SD.
What is the long example for?
Opening of position
OnTradeTransaction
Place stops
Request#1348574
Ok
How's that?
And you do not perform trade operations from OnTradeTransaction by any chance?
Why the long example?
Position opening
OnTradeTransaction
Setting stops
Ok
Yes, from there? Any restrictions?
More. In OHLC M1 simulation mode - everything is OK.
Yes, from there? Are there restrictions?
The limitations are purely event-based
You run the risk of not getting out of OnTradeTransaction processing for a very long time - just processed, and the next transaction you just spawned is coming up
Try instead of a simple print
Make this print
And look.
For me, for example, judging by the prints, there is no doubling of events
Here is the log from 15 minutes, like you
Try instead of a simple print
Make a print like this.
And take a look.
I, for example, judging from the prints, don't have any event doubling.
Here's a log from a 15-minute print like yours.
Tried your option. As I said earlier, the error is "floating". It's not always possible to repeat it. And I have the log from the M5.
From the logs, it looks like an error:
Transactions are clones. Exactly the same. On OHLC M1 - no such thing.