Discussion of article "Library for easy and quick development of MetaTrader programs (part X): Compatibility with MQL4 - Events of opening a position and activating pending orders" - page 4

 
Artyom Trishkin:

No. Just read the articles

Sorry, but I don't know that many letters. )))

 
Alexey Viktorov:

And this is what happened:

While I was running this code on the demo, a limit order was set and deleted.

And suddenly, during the next mocking, one position was modified, one position was opened and one position was closed. But where did the record of deleting a long deleted order come from?

Did you replace the library with the files I gave you? The library in this article is not finished yet - it has this flaw - when two events have the same criteria for MQL4. In the eleventh article, porting of the current functionality of the library to MQL4 has been completed. And the version from this article has this bug, and its presence is indirectly indicated by the final words in the article:

What's Next

In the next article, we will make position closing tracking and fix the errors that may occur in the current implementation of event tracking for MQL4 - because the installation and deletion of orders is tracked by the code for MQL5, and there may be some nuances that need to be taken into account when working under MQL4.
If you have replaced the library files, but the error still occurs, you need to catch the situation when it occurs - the sequence of actions leading to the error, and I will fix it.
 
Artyom Trishkin:

Did you replace the library with the files I gave you? The library in this article is not finished yet - it has this flaw - when two events have the same criteria for MQL4. In the eleventh article, porting of the current functionality of the library to MQL4 has been completed. But the version from this article has this bug, and its presence is indirectly indicated by the final words in the article:

What's Next

In the next article, we will make position closing tracking and fix the errors that may occur in the current implementation of event tracking for MQL4 - because the installation and deletion of orders is tracked by the code for MQL5, and there may be some nuances that need to be taken into account when working under MQL4.
If you have replaced the library files, but the error still occurs, you need to catch the situation when it occurs - the sequence of actions leading to the error, and I will fix it.

Yes, I did. I have already described the sequence

Forum on trading, automated trading systems and testing trading strategies.

Discussion of the article "Library for easy and fast creation of programmes for MetaTrader (Part X): Compatibility with MQL4 - Events of position opening and pending order activation"

Alexey Viktorov, 2019.05.27 17:59

And here is such an incomprehensible thing happened:

While I was running this code on the demo a limit order was set and deleted

443342388 2019.05.27 14:54:10 buy limit 0.01 eurusd 1.11835 0.00000 0.00000 2019.05.27 15:01:14 1.11972 cancelled 

And suddenly during the next mocking was modified one position, one open and one close. But that's where the record of deleting a long deleted order came from?

2019.05.27 18:34:11.903 00 EURUSD,H1: OnChartEvent: id=1002, event=TRADE_EVENT_PENDING_ORDER_REMOVED, lparam=443342388, dparam=1.11835, sparam=EURUSD
2019.05.27 18:34:11.903 00 EURUSD,H1: OnChartEvent: id=1024, event=TRADE_EVENT_POSITION_CLOSED, lparam=443417294, dparam=1.11933, sparam=EURUSD
2019.05.27 18:34:11.903 00 EURUSD,H1: - Отложенный ордер удалён: 2019.05.27 14:54:10.000 -
EURUSD Удалён 0.01 Buy Limit #443342388  по цене 1.11835
2019.05.27 18:34:11.903 00 EURUSD,H1: - Позиция закрыта: 2019.05.27 18:33:02.000 -
EURUSD Закрыт Sell #443417294  по цене 1.11912, профит -0.21 USD
2019.05.27 18:33:02.755 00 EURUSD,H1: OnChartEvent: id=1022, event=TRADE_EVENT_POSITION_OPENED, lparam=443417294, dparam=1.11912, sparam=EURUSD
2019.05.27 18:33:02.755 00 EURUSD,H1: - Позиция открыта: 2019.05.27 18:33:02.000 -
EURUSD Открыт 0.01 Sell #443417294 [0.01 Market order Sell #443417294]  по цене 1.11912
2019.05.27 18:29:21.913 00 EURUSD,H1: OnChartEvent: id=1050, event=TRADE_EVENT_MODIFY_POSITION_TAKE_PROFIT, lparam=443218277, dparam=1.12218, sparam=EURUSD
2019.05.27 18:29:21.913 00 EURUSD,H1: - Модифицирован TakeProfit позиции: 2019.05.27 18:27:45.000 -
EURUSD Buy #443218277:  модифицирован TakeProfit: [1.12240 --> 1.12218]

At 15:01:14 I deleted a limit order placed earlier.

Until 18:29 I was doing my own business. The Expert Advisor stood on the chart.

At 18:29:21 I modified the previously set position.

At 18:33:02 I put Sell

At 18:34:11, I closed this Sell.

And at that moment I received the second record that the limit that was deleted at 15:01:14 has been removed.

 
Alexey Viktorov:

Yes, I did. I already described the sequence, didn't I?

You did:

And this is what happened:

While I was running this code on the demo, a limit order was set and deleted.

And suddenly during the next mocking one position was modified, one position was opened and one position was closed. But that's where the record of deleting a long deleted order came from?

And what is the sequence of these actions?

  1. set a limit order
  2. deleted a limit order
  3. position modified (when was it opened?)
  4. position is opened
  5. the same position is closed
At what moment did the incorrect event appear?
 
Artyom Trishkin:

You wrote:

What is the sequence of these actions?

  1. set a limit order
  2. deleted a limit order
  3. position modified (when was it opened?)
  4. position is opened
  5. the same position was closed
At what point did the incorrect event appear?

I have completed the previous message.

 
Alexey Viktorov:

Yes, I did. I already described the sequence, didn't I?


I can't get this error in any sequence.

Please describe the sequence leading to it.

It is better not in the log - there are a lot of debugging records there now, which interfere with quick perception, but right here in a numbered list.

 
Alexey Viktorov:

I have completed the previous message.

At 15:01:14 I deleted the limit order placed earlier.

Until 18:29 I was doing my own things. The Expert Advisor stood on the chart.

At 18:29:21 I modified the previously set position.

At 18:33:02 I put Sell

At 18:34:11, I closed this Sell.

And at that moment I received a second record that the limit that was deleted at 15:01:14 has been deleted.

I.e., you need to:

  1. open a position, wait for some time,
  2. place a limit order, wait a certain time,
  3. delete the limit order,
  4. modify the position,
  5. open the position and close the position
Right?
 
Artyom Trishkin:

At 15:01:14 I deleted the limit order placed earlier.

Until 18:29 I was doing my own things. The Expert Advisor stood on the chart.

At 18:29:21 I modified the previously set position.

At 18:33:02 I put Sell

At 18:34:11, I closed this Sell.

And at that moment I received the second record that the limit that was deleted at 15:01:14 has been removed.

I.e., I need to:

  1. open a position, wait for some time,
  2. place a limit order, wait a certain time,
  3. remove the limit order,
  4. modify the position,
  5. open the position and close the position
Right?

No, watch your hands.

443342388 2019.05.27 14:54:10 buy limit 0.01 eurusd 1.11835 0.00000 0.00000 2019.05.27 15:01:14 1.11972 cancelled 

Limit set at 14:54:10 and removed at 15:01:14.

Then a long break in broadcasting. Everything goes silent.

Then several movements in a row, at 18:. listing only minutes 29, 33 and 34. At 34, this event that happened three and a half hours ago comes through.

Here's the list of positions.

443217459 2019.05.27 08:48:18 buy 0.01 eurusd 1.12109 0.00000 0.00000   1.11933 0.00 0.00 0.00 -1.76 
443218277 2019.05.27 08:51:53 buy 0.01 eurusd 1.12112 0.00000 1.12218   1.11933 0.00 0.00 0.00 -1.79 
443335401 2019.05.27 14:31:07 buy 0.01 eurusd 1.11965 0.00000 0.00000   1.11933 0.00 0.00 0.00 -0.32 
443336857 2019.05.27 14:35:47 buy 0.01 eurusd 1.11970 0.00000 0.00000   1.11933 0.00 0.00 0.00 -0.37 
443336959 2019.05.27 14:36:09 buy 0.01 eurusd 1.11967 0.00000 0.00000   1.11933 0.00 0.00 0.00 -0.34 
443337190 2019.05.27 14:36:53 buy 0.01 eurusd 1.11967 0.00000 0.00000   1.11933 0.00 0.00 0.00 -0.34 
They're all open in the morning and at lunchtime. At 18 minutes, only Sell was open and almost immediately closed.
 
Alexey Viktorov:

No, well, watch your hands

Limit set at 14:54:10 and deleted at 15:01:14.

Then a long break in broadcasting. Everything goes silent.

Then several movements in a row, at 18:. listing only minutes 29, 33 and 34. Now, at 34, this event that happened three and a half hours ago.

Here's a list of positions.

They're all open in the morning and at lunchtime. At 18 minutes, only Sell was open and almost immediately closed.

Well, there you go:

At 15:01:14, I deleted a limit order placed earlier.

Until 18:29 I was doing my own business. The Expert Advisor stood on the chart.

At 18:29:21 I modified the previously set position.

At 18:33:02 I put Sell

At 18:34:11 I closed this Sell.

Earlier - is it BEFORE setting the limit order? Or after? When it was opened? "Earlier" is not specific. There's probably significance in the timing of all actions - everything is saved to the list, after all. Somewhere there are equal conditions, since the removal of the old limit order is determined again at the moment of closing the position - the position was closed, we checked the conditions (it is described directly in the code) and determined the type of event based on these conditions. And then the list is sorted by the type of a certain order in the event and the event is sent to the programme - so there is an overlap of conditions in MQL4 that they turn out to be equal for the library. Although this is what I have removed in the 11th article, which is still being tested.

 
Artyom Trishkin:

Well, here you are writing:

At 15:01:14 I deleted a limit order placed earlier.

Until 18:29, I did my own thing. The Expert Advisor stood on the chart.

At 18:29:21 I modified the previously set position.

At 18:33:02 I put Sell

At 18:34:11 I closed this Sell.

Previously - is that BEFORE the limit order was set? Or after? When it was opened? "Earlier" is not specific. There's probably significance in the timing of all the actions - everything is saved to the list, after all. Somewhere there are equal conditions, since the removal of the old limit order is determined again at the moment of closing the position - the position was closed, we checked the conditions (it is described directly in the code) and determined the type of event based on these conditions. And then the list is sorted by the type of a certain order in the event and the event is sent to the programme - so there is an overlap of conditions in MQL4 that they turn out to be equal for the library. Although this is what I have removed in the 11th article, which is still being tested.

Forum on trading, automated trading systems and testing trading strategies

Discussion of the article "Library for easy and fast creation of programmes for MetaTrader (Part X): Compatibility with MQL4 - Events of position opening and pending orders activation"

Alexey Viktorov, 2019.05.27 18:50

No, well watch your hands

443342388 2019.05.27 14:54:10 buy limit 0.01 eurusd 1.11835 0.00000 0.00000 2019.05.27 15:01:14 1.11972 cancelled 

Limiter put at 14:54:10 and deleted at 15:01:14

Then a long break in broadcasting. Everything goes silent.

Then several movements in a row, at 18:. listing only minutes 29, 33 and 34. Now, at 34, this event that happened three and a half hours ago.

Here's the list of positions.

443217459 2019.05.27 08:48:18 buy 0.01 eurusd 1.12109 0.00000 0.00000   1.11933 0.00 0.00 0.00 -1.76 
443218277 2019.05.27 08:51:53 buy 0.01 eurusd 1.12112 0.00000 1.12218   1.11933 0.00 0.00 0.00 -1.79 
443335401 2019.05.27 14:31:07 buy 0.01 eurusd 1.11965 0.00000 0.00000   1.11933 0.00 0.00 0.00 -0.32 
443336857 2019.05.27 14:35:47 buy 0.01 eurusd 1.11970 0.00000 0.00000   1.11933 0.00 0.00 0.00 -0.37 
443336959 2019.05.27 14:36:09 buy 0.01 eurusd 1.11967 0.00000 0.00000   1.11933 0.00 0.00 0.00 -0.34 
443337190 2019.05.27 14:36:53 buy 0.01 eurusd 1.11967 0.00000 0.00000   1.11933 0.00 0.00 0.00 -0.34 
They're all open in the morning and at lunchtime. At 18 minutes, only one was open, Sell, and almost immediately closed.

Modified only one, the highlighted position. There's no doubt about it. It was placed in the morning. Modified it several times. I didn't care which one I modified. I had already set a takeout on this one. That's what I was trying to do.

Here are all the limiters and the last Sell.

443340041 2019.05.27 14:46:32 buy limit 0.01 eurusd 1.11815 0.00000 0.00000 2019.05.27 14:46:55 1.11974 cancelled 
443340283 2019.05.27 14:47:15 buy limit 0.01 eurusd 1.11796 0.00000 0.00000 2019.05.27 14:47:27 1.11974 cancelled 
443340764 2019.05.27 14:48:42 buy limit 0.01 eurusd 1.11830 0.00000 0.00000 2019.05.27 14:52:51 1.11962 cancelled 
443340819 2019.05.27 14:48:54 buy limit 0.01 eurusd 1.11761 0.00000 0.00000 2019.05.27 14:50:22 1.11977 cancelled 
443340874 2019.05.27 14:49:06 buy limit 0.01 eurusd 1.11694 0.00000 0.00000 2019.05.27 14:52:37 1.11963 cancelled 
443341012 2019.05.27 14:49:32 buy limit 0.01 eurusd 1.11657 0.00000 0.00000 2019.05.27 14:51:22 1.11973 cancelled 
443342301 2019.05.27 14:53:55 sell stop 0.01 eurusd 1.11764 0.00000 0.00000 2019.05.27 15:01:03 1.11956 cancelled 
443342388 2019.05.27 14:54:10 buy limit 0.01 eurusd 1.11835 0.00000 0.00000 2019.05.27 15:01:14 1.11972 cancelled 
443417294 2019.05.27 18:33:02 sell 0.01 eurusd 1.11912 0.00000 0.00000 2019.05.27 18:34:11 1.11933 0.00 0.00 0.00 -0.21 

The deleted limiters and the Sell are highlighted. The deletion event must have been left somewhere. But why did it "wake up" not with the opening of this Sell, but only with the closing of the Sell?