[Archive!] Any rookie question, so as not to clutter up the forum. Professionals, don't pass it by. Couldn't go anywhere without you - 2. - page 533

 
Sancho77:

Dear, I am testing an EA in the tester and the log shows error 138. I mean, the tester generates requotes? I suspect I have an error somewhere in this part of the code

If you really have an error, please advise me what is wrong?

Probably the wrong price in OrderClose()
 
PapaYozh:

Probably incorrect price in OrderClose()
How can I check/correct?
 
Sancho77:
How do you check/correct?

Use the price valid at the time the request was sent to the server.
 
PapaYozh:

Use the valid price at the time the request is sent to the server.
Don't I use RefreshRates to get a valid price?
 
Sancho77:
How can I check/correct ?


Actually, there is a branch of psychics waiting for this question. It's not clear from your code what kind of order you are closing.

Is it OP_BUY ?

OrderSymbol() is the same as Symbol() ?

 
Sancho77:
Don't I get a valid price with RefreshRates?


You do if RefreshRates() returns true.

The only question is: "is the Bid the price at which the order can be closed?"

 
PapaYozh:


Actually, the psychic branch is waiting for this question. It is not clear from your code what order you are closing.

Is it OP_BUY ?

OrderSymbol() is the same as Symbol() ?


OrderSymbol() is equal to Symbol()

I close all open orders both longs and shorts.

PapaYozh:


You do if RefreshRates() returns true.

The only question is: "is Bid the price at which the order can be closed?"

I.e. to separate the closing of longs and shorts?

 
Sancho77:

OrderSymbol() is the same as Symbol()

I close all open orders, both longs and shorts.


What are the other shorts at Bid price ?

Only orders of OP_BUY type can be closed by Bid

 
PapaYozh:


what other shorts at Bid price ?

Only orders of type OP_BUY can be closed at Bid

Thanks for the help!
 
Sancho77:

OrderSymbol() is the same as Symbol()

I close all open orders both longs and shorts.

I.e. separate the closing of longs and shorts?


if ( OrderType()=OP_BUY )
   OrderClose(OrderTicket(), OrderLots(), Bid, Slippage, Orange);
else if ( OrderType()=OP_SELL )
   OrderClose(OrderTicket(), OrderLots(), Ask, Slippage, Orange);