When I try to refer to the order, I try using "ticket"(OrderSelect(ticket,SELECT_BY_TICKET)).
What is that supposed to do??
-
int ticket=OrderSend(Symbol(),OP_BUY,1,Ask,5,0,0,NULL,12345,0,clrBlue);
Check your return codes, and report your errors (including market prices and your variables). Don't look at GLE/LE unless you have an error. Don't just silence the compiler (strict), it is trying to help you.
What are Function return values ? How do I use them ? - MQL4 programming forum 2012.05.20
Common Errors in MQL4 Programs and How to Avoid Them - MQL4 Articles 25 March 2014 - HosseinKOGO: But it is always 0. What is my misunderstanding?OrderSelect does not return an int.
-
If the OrderSend failed, you don't have a valid ticket to select.
-
Always post all relevant code.
How To Ask Questions The Smart Way. 2004
Be precise and informative about your problem
When I try to refer to the order, I try using "ticket"(OrderSelect(ticket,SELECT_BY_TICKET)).
What is that supposed to do??
I mean I use
if(OrderSelect(ticket,SELECT_BY_TICKET)==true)
to just select the recent opened order. Which
ticket = OrderSend(...);
and when I comment(ticket), it is "0"
-
Check your return codes, and report your errors (including market prices and your variables). Don't look at GLE/LE unless you have an error. Don't just silence the compiler (strict), it is trying to help you.
What are Function return values ? How do I use them ? - MQL4 programming forum 2012.05.20
Common Errors in MQL4 Programs and How to Avoid Them - MQL4 Articles 25 March 2014 - OrderSelect does not return an int.
-
If the OrderSend failed, you don't have a valid ticket to select.
-
Always post all relevant code.
How To Ask Questions The Smart Way. 2004
Be precise and informative about your problem
Sorry I mislead you, I mean when I use
if(OrderSelect(ticket,SELECT_BY_TICKET)==true) ...
it does not select the last recent opened order however
ticket= OrderSend(...);
- The OrderSend() is successful since it draw object in visual mode and really opens an order.
I have tried to make it shorter to take less time of you, but here is my original code and thank you for your time:
int Buys() { BuyTicket[x]=OrderSend(Symbol(),OP_BUY,LotSize*BuyZarib,Ask,Slippage,0,0,NULL,MagicA,0,clrBlue); if(BuyTicket[x]>=0) { x++; return(0); } return(0); }
And I defined
int BuyTicket[100];
in global area to support up to 100 buy orders.
I defined x in global area as int also
Are you sure about that ?
Because last time i checked, OrderSend() returns number of the ticket assigned to the order by the trade server or -1 if it fails.
So it's either the ticket number, or -1 and not 0.
Maybe its a good idea if you post the complete code.
Are you saying that,
int Buys() { BuyTicket[x]=OrderSend(Symbol(),OP_BUY,LotSize*BuyZarib,Ask,Slippage,0,0,NULL,MagicA,0,clrBlue); Print(BuyTicket[x]); if(BuyTicket[x]>=0) { x++; return(0); } return(0); }
This prints out 0 ?
Are you saying that,
This prints out 0 ?
No I put Comment func in my Start func.
you pointed right to my problem. When I put my Comment in Buys(), it has value. But why its value is 0 when I put it in Start()?
Maybe because of this
return(0);And otherwise, again maybe its a good idea to post the complete code.
Maybe because of this
And otherwise, again maybe its a good idea to post the complete code.I got it!
Thank you for your pointing. The reason is: when BuyTicket[x] have last order ticket, it increases x by 1 so in start function when I Comment(BuyTicket[x]), It is actually BuyTicket[x+1] which logically has no value.
Again thanks to all people engaged in my problem.
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hi There,
As the documentation says, the OrderSend function:
Ord Returns number of the ticket assigned to the order by the trade server or -1 if it fails.
It should return the recent opened ticket number right?
But it always return 0 for me...
Here is my code:
When I try to refer to the order, I try using "ticket"(OrderSelect(ticket,SELECT_BY_TICKET)). But it is always 0. I figured it out by using Comment function in start();
What is my misunderstanding?
Your Advice is appreciated.