PositionSelect() question

 

Hello,

Ihave the following code in an EA

 if(PositionSelect(_Symbol))
   .....
  else
   Print(GetLastError());

 From time to time, I did not count it, but around 10-20% I receive error 4753

Does anyone met this situation ?

What is the problem and how could be resolve ?

Thank in advance ! 

 
tenlau:

Hello,

Ihave the following code in an EA

 From time to time, I did not count it, but around 10-20% I receive error 4753

Does anyone met this situation ?

What is the problem and how could be resolve ?

Thank in advance ! 

See this topic My EA does a double entry
 

A little bit more information:

Code is:

trade.PositionOpen(_Symbol,signal,TradeSizeOptimized(),
                            SymbolInfoDouble(_Symbol,signal==ORDER_TYPE_SELL ? SYMBOL_BID:SYMBOL_ASK),
                            MyStopLoss,MyTakeProfit);
 if(PositionSelect(_Symbol)==true)
   .......
  else
   Print(GetLastError());
 
I have to specify that the position is opening but the code of branch else is executed; so I have 4753 error
 
angevoyageur:
See this topic My EA does a double entry
I read something from this topic, not entirely. Sorry, I do not see what has in common with my problem.
 
My EA does not do a double entry. It does an entry but  if(PositionSelect(_Symbol)==true) returns error 4753
 

And BTW, the topic you mentioned above ends with your comment:

"I don't think so. A synchronous trading request have to be synchronous in all the aspects. It's as simple as that.

Here the request is synchronous but then you have to manage asynchronous stuff. And nothing is documented about that."

So, to understand there is no conclusion to the problem, yet ? 

 
Really ? I guess I have to explain that
 
angevoyageur:
Really ? I guess I have to explain that

The link I post is fully related to your issue. The symptom isn't the same, the underlying problem is the same.

There can sometimes exist a delay for the Terminal to be informed that a new position is open (or close, doesn't matter). So when PositionSelect(...) is reached your "else" is executed. There are several workaround explained in the topic I gave you the link.

 
angevoyageur:

The link I post is fully related to your issue. The symptom isn't the same, the underlying problem is the same.

There can sometimes exist a delay for the Terminal to be informed that a new position is open (or close, doesn't matter). So when PositionSelect(...) is reached your "else" is executed. There are several workaround explained in the topic I gave you the link.

Thanks for clarifications. But the question remain: how can be avoid this kind of problem?

I mean: how to code to avoid this situation.

 
tenlau:

Thanks for clarifications. But the question remain: how can be avoid this kind of problem?

I mean: how to code to avoid this situation.

Please, some efforts, I already wrote you that :

There are several workaround explained in the topic I gave you the link.

Sorry but I don't have time to repeat and resume it for you.
Reason: