beginners question: is zero a valid ticket nr

Back to topics list To post a new topic, please log in or register
avatar
4
tomtester 2015.01.28 10: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

avatar
735
honest_knave 2015.01.28 10: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.

 

avatar
4
tomtester 2015.01.28 10: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());
}
avatar
2017
gooly 2015.01.28 10: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.

avatar
Moderator
3206
angevoyageur 2015.01.28 11: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://forum.mql4.com/51290
avatar
49
gadget 2015.01.28 15: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).


avatar
4
tomtester 2015.01.28 15: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?

avatar
735
honest_knave 2015.01.28 16: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. 

 

 

Back to topics list  

To add comments, please log in or register