beginners question: is zero a valid ticket nr

 

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

 

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.

 
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());
}
 

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.

 
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
 
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).

 

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?

 
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.