OrderType() is incorrect

 

My EA places only market orders. The text "SELLSTOP" and "BUYSTOP" don't appear anywhere in it. The trade window shows only "buy" and "sell" orders since I never sent anything else.

Yet OrderType() in MQL4 returns them as being types 4 and 5, BUYSTOP and SELLSTOP. OrderTicket() returns the same ticket number as in the trade window, so I know there's no mistake about which ticket I'm looking at.

I guess I can work around it by testing for OP_BUYSTOP in addition to OP_BUY, but that seems awfully sloppy.

My test for OP_BUY and OP_SELL used to work - what changed?.

Is this happening to anyone else?

------------------------------------------

This is strange: I'm going to post the above anyway.

I restarted the terminal and now OrderType() is returning 0 which is OP_BUY which is correct. I'm trying to understand how the client would mess up this information. I mean, I assumed the OrderType() to be retuned directly from the server each time.

Any thoughts?

 
LouK:

My EA places only market orders. The text "SELLSTOP" and "BUYSTOP" don't appear anywhere in it. The trade window shows only "buy" and "sell" orders since I never sent anything else.

Yet OrderType() in MQL4 returns them as being types 4 and 5, BUYSTOP and SELLSTOP. OrderTicket() returns the same ticket number as in the trade window, so I know there's no mistake about which ticket I'm looking at.

I guess I can work around it by testing for OP_BUYSTOP in addition to OP_BUY, but that seems awfully sloppy.

My test for OP_BUY and OP_SELL used to work - what changed?.

Is this happening to anyone else?

------------------------------------------

This is strange: I'm going to post the above anyway.

I restarted the terminal and now OrderType() is returning 0 which is OP_BUY which is correct. I'm trying to understand how the client would mess up this information. I mean, I assumed the OrderType() to be retuned directly from the server each time.

Any thoughts?

When I first read your post my thought was that you had an "error" with your OrderSelect() calls . . . print all the related variables just before you call OrderType() and after . . . so Print() OrderTicket() to make sure you have the correct order selected.
 
RaptorUK:
When I first read your post my thought was that you had an "error" with your OrderSelect() calls . . . print all the related variables just before you call OrderType() and after . . . so Print() OrderTicket() to make sure you have the correct order selected.


As I said in my post, I also returned OrderTicket() with OrderType(), so there was no mistake about which order. It matched the ticket number in the trade window.

It's all working now, I just don't understand what a restart had to do with it.

Thanks for the reply!

 

LouK:

I restarted the terminal and now OrderType() is returning 0 which is OP_BUY which is correct. I'm trying to understand how the client would mess up this information. I mean, I assumed the OrderType() to be retuned directly from the server each time.

Any thoughts?

I believe OrderType() is returned by the terminal.