MetaEditor build 1490 - page 4

 
Andrey Dik:

No, it's not normal.

There is a position. We will throw the Expert Advisor to the chart. There is no deal history for the selected position. What is normal here?))

The position has been open for several seconds, and the number of deals is still zero?
 
fxsaber:
A position has been open for a few seconds and the number of trades is still zero?
Exactly.
 
Andrey Dik:
Exactly.
Then it's very bad for everyone who trades in MT5. How do you reproduce it?
 
fxsaber:
Then it's very bad for anyone trading in MT5. How to reproduce?
open positions without and with an EA on a chart, add to a position, cut a position, flip a position. the bug is not always and not immediately apparent. i experimented on a fibo demo account, build 1490
 
Andrey Dik:
The bug is not always and not immediately apparent. I tried it on a fibo demo account, build 1490
Do not reproduce
void OnTick ()
{
  const int Total = PositionsTotal();
  
  for (int i = 0; i < Total; i++)
  {
    const ulong Ticket = PositionGetTicket(i);
    
    if (PositionSelectByTicket(Ticket) && HistorySelectByPosition(PositionGetInteger(POSITION_IDENTIFIER)) && (HistoryDealsTotal() == 0))
      Alert(Ticket);
  }
}
 
fxsaber:
Can't reproduce.
void OnTick ()
{
  const int Total = PositionsTotal();
  
  for (int i = 0; i < Total; i++)
  {
    const ulong Ticket = PositionGetTicket(i);
    
    if (PositionSelectByTicket(Ticket) && HistorySelectByPosition(PositionGetInteger(POSITION_IDENTIFIER)) && (HistoryDealsTotal() == 0))
      Alert(Ticket);
  }
}
Your position is selected differently. Try my code.
 
Andrey Dik:
Your position is selected differently. Try my code.
And it doesn't play that way.
void OnInit()
{
  EventSetMillisecondTimer(1);
}

void OnTimer()
{
  const int Total = PositionsTotal();
  
  for (int i = 0; i < Total; i++)
    if ((PositionGetSymbol(i) == _Symbol) && HistorySelectByPosition(PositionGetInteger(POSITION_IDENTIFIER)) && (HistoryDealsTotal() == 0))
      Alert(PositionGetInteger(POSITION_TICKET));
}
 
fxsaber:
And it's not playing.
void OnInit()
{
  EventSetMillisecondTimer(1);
}

void OnTimer()
{
  const int Total = PositionsTotal();
  
  for (int i = 0; i < Total; i++)
    if ((PositionGetSymbol(i) == _Symbol) && HistorySelectByPosition(PositionGetInteger(POSITION_IDENTIFIER)) && (HistoryDealsTotal() == 0))
      Alert(PositionGetInteger(POSITION_TICKET));
}

Have you tried my code?

To reproduce it in the same way and get the same logs.

 
Andrey Dik:

Have you tried my code?

To reproduce it in the same way and get the same logs.

Tried it - the problem does not reproduce.
 
fxsaber:
I tried - the problem is not reproduced.

Strange.... What could be the problem then?

Here. Doing this. Started the Expert Advisor on a chart. I opened a position manually. I have added a position twice and cut it once. It shows 4 trades correctly in lags. After that I reversed the position and got a problem: I have a position but no deals.

Here is the log after the last two operations.

2016.12.05 14:25:44.157 Get current commission of pos (GBPUSD,M5) 1

2016.12.05 14:25:44.157 Get current commission of pos (GBPUSD,M5) GBPUSD

2016.12.05 14:25:44.157 Get current commission of pos (GBPUSD,M5) Position found

2016.12.05 14:25:44.157 Get current commission of pos (GBPUSD,M5) Total trades in position: 4

2016.12.05 14:25:44.670 Get current commission of pos (GBPUSD,M5) 1

2016.12.05 14:25:44.670 Get current commission of pos (GBPUSD,M5) GBPUSD

2016.12.05 14:25:44.670 Get current commission of pos (GBPUSD,M5) Position found

2016.12.05 14:25:44.670 Get current commission of pos (GBPUSD,M5) Total trades in position: 0

It can be seen that no trades are seen in the position. EA is still hanging on the chart and there is 0 in the comment.

I removed the EA and reset it to the chart, it does not see trades of a position, the comment is 0.

Reason: