Download MetaTrader 5
To add comments, please log in or register
Find out how social trading can improve your profits
Tom Test
19
Tom Test 2015.01.28 09:01 

Dear MQL4 Forum members,

I'm new to mql4/mql5 and this forum. I've a question which I couldn't figure out by reading documentation or searching the web/this forum:
Is 0 (zero) a valid/possible ticket number?
In other words is it possible (although unlikely) that OrderSend returns ZERO as a valid ticket number?

Kind regards, Tom

honest_knave
954
honest_knave 2015.01.28 09:11  

I would say that would depend entirely on the broker because the ticket number is generated from the trade server.

However unlikely 0 would be as an order number, all you can know with certainty is that -1 means that the OrderSend() failed.

Tom Test
19
Tom Test 2015.01.28 09:31  
honest_knave:

I would say that would depend entirely on the broker because the ticket number is generated from the trade server.

However unlikely 0 would be as an order number, all you can know with certainty is that -1 means that the OrderSend() failed.

 

Thanks for your answer!
On the other hand calling OrderTicket() without calling OrderSelect() seems to return zero (independent of broker ??), which could lead to the impression that zero is not a valid ticket nr?

example script:

void OnStart() {
   Print("pre: ", OrderTicket());
}
Carl Schreiber
5938
Carl Schreiber 2015.01.28 09:52  

Check the errors!

Look in your expert folder there you have 2 sample EAs with a valid order control.

There you can see when and how to check the error of your orders sent.

Alain Verleyen
Moderator
28536
Alain Verleyen 2015.01.28 10:19  
tomtester:

Dear MQL4 Forum members,

I'm new to mql4/mql5 and this forum. I've a question which I couldn't figure out by reading documentation or searching the web/this forum:
Is 0 (zero) a valid/possible ticket number?
In other words is it possible (although unlikely) that OrderSend returns ZERO as a valid ticket number?

Kind regards, Tom

https://www.mql5.com/en/forum/141302
gadget
100
gadget 2015.01.28 14:35  
tomtester:

Thanks for your answer!
On the other hand calling OrderTicket() without calling OrderSelect() seems to return zero (independent of broker ??), which could lead to the impression that zero is not a valid ticket nr?

example script:

Order number and order ticket are not the same, the first is an index.

OrderTicket() must be called after selecting an order (by index or by ticket).

Tom Test
19
Tom Test 2015.01.28 14:38  

In my opinion, this does not really answer my question. There are merely marginalia about it. I tend not to belive in marginalia.



gooly:

Check the errors!

Look in your expert folder there you have 2 sample EAs with a valid order control.

There you can see when and how to check the error of your orders sent.

I've already looked into that. In MACD Sample the ticket is checked if it's bigger than zero.
In the other (Moving Average) there is no check at all. Why? I don't think this is good practice?

On the other hand, even the mql4 documentation itself seems to be erroneous in some places (e.g. return data type long instead of int etc.) and quite incomplete in other places.

So whom to belive?

honest_knave
954
honest_knave 2015.01.28 15:15  
gadget:

Order number and order ticket are not the same, the first is an index.

OrderTicket() must be called after selecting an order (by index or by ticket).


I think this is becoming a discussion of semantics, which is not entirely helped by the MT documentation.

OrderTicket() = ticket number (note the use of both terms in the documentation)

When you use OrderSelect(), you make a distinction between  SELECT_BY_POS and SELECT_BY_TICKET. If you use SELECT_BY_TICKET you are entering the ticket number as a parameter labelled index. Not entirely helpful for clarity!

But generally speaking, each order will have a 'ticket number' plus an index in the order pool. 

/
To add comments, please log in or register