I have no idea. Add some checks, e.g.
Alert("TicketNumber:",TicketNumber);
and see if it's right.
Are you SURE it's return false? How are you checking the return value?
Do you know that if OrderSelect returns true, and OrderType is not OP_SELL than OpenBuy() is not triggered?
Add this alert:
Alert("OrderSelected:",(OrderSelect(TicketNumber, SELECT_BY_TICKET));
0 = false, 1 = true;
Also, add this code after OrderSelect:
int error = GetLastError(); if(error !=0) Alert("error:",error);
Basically, learn to solve it yourself
hi..
Thank you for your advise..
Its display message as below:
Aler: OrderSelect: 0
int TicketNumber = 12345; ... ... ... int GetTicketNumber (int TicketNumber, string symbol, int timeFrame) { int isymbol = 0; if (symbol == "EURUSD") isymbol = 1; else if (symbol == "GBPUSD") isymbol = 2; else if (symbol == "USDJPY") isymbol = 3; else if (symbol == "USDCHF") isymbol = 4; else if (symbol == "AUDUSD") isymbol = 5; else if (symbol == "USDCAD") isymbol = 6; else if (symbol == "EURGBP") isymbol = 7; else if (symbol == "EURJPY") isymbol = 8; else if (symbol == "EURCHF") isymbol = 9; else if (symbol == "EURAUD") isymbol = 10; else if (symbol == "EURCAD") isymbol = 11; else if (symbol == "GBPUSD") isymbol = 12; else if (symbol == "GBPJPY") isymbol = 13; else if (symbol == "GBPCHF") isymbol = 14; else if (symbol == "GBPAUD") isymbol = 15; else if (symbol == "GBPCAD") isymbol = 16; else isymbol = 17; return (TicketNumber + isymbol); //return (StrToInteger(StringConcatenate(TicketNumber, isymbol, timeFrame))); } int init() { TicketNumber = GetTicketNumber( TicketNumber, Symbol(), Period() ); return (0); } void OpenBuy() { if (MinProfit > 0) { OrderSend(Symbol(),OP_BUY,lot,Ask,1,0,Ask+MinProfit*Point,"arnab",TicketNumber,0,Blue); } else { OrderSend(Symbol(),OP_BUY,lot,Ask,1,0,0,"arnab",TicketNumber,0,Blue); } } void CloseSell() { OrderClose(OrderTicket(), OrderLots(), Bid, 3, Red); } void OpenSell() { if (MinProfit > 0) { OrderSend(Symbol(),OP_SELL,lot,Bid,1,0,Bid-MinProfit*Point,"arnab",TicketNumber,0,Red); } else { OrderSend(Symbol(),OP_SELL,lot,Bid,1,0,0,"arnab",TicketNumber,0,Red); } } void CloseBuy() { OrderClose(OrderTicket(), OrderLots(), Ask, 3, Blue); } ... ... ... if (Test > 0) { Alert("Orderselect: ", (OrderSelect(TicketNumber, SELECT_BY_TICKET))); if (OrderSelect(TicketNumber, SELECT_BY_TICKET) == true) { error = GetLastError(); if (error != 0) Alert("error:", error); if (OrderType() == OP_SELL) { Print ("SELL OrderType: " + OrderType()); CloseSell(); OpenBuy(); } } else { OpenBuy(); } } else { Alert("Orderselect: ", (OrderSelect(TicketNumber, SELECT_BY_TICKET))); if (OrderSelect(TicketNumber, SELECT_BY_TICKET) == true) { error = GetLastError(); if (error != 0) Alert("error:", error); if (OrderType() == OP_BUY) { CloseBuy(); OpenSell(); } } else { OpenSell(); } }
Thank you
hi..
Thank you for your advise..
Its display message as below:
Aler: OrderSelect: 0
Thank you
hi..
This is the setting:-
int TicketNumber = 12345;
or you can refer to my previous thread as above...i have edit the code...
Thank you and please guide me... i have no ideas to solve this problem..
hi..
This is the setting:-
int TicketNumber = 12345;
or you can refer to my previous thread as above...i have edit the code...
Thank you and please guide me... i have no ideas to solve this problem..
What does this code do to the ticket number ?
TicketNumber = GetTicketNumber( TicketNumber, Symbol(), Period() );
Hi...
The GetTicketNumber function called to create TicketNumber based on symbol and timeframe..The code as below:-
int GetTicketNumber (int TicketNumber, string symbol, int timeFrame) { int isymbol = 0; if (symbol == "EURUSD") isymbol = 1; else if (symbol == "GBPUSD") isymbol = 2; else if (symbol == "USDJPY") isymbol = 3; else if (symbol == "USDCHF") isymbol = 4; else if (symbol == "AUDUSD") isymbol = 5; else if (symbol == "USDCAD") isymbol = 6; else if (symbol == "EURGBP") isymbol = 7; else if (symbol == "EURJPY") isymbol = 8; else if (symbol == "EURCHF") isymbol = 9; else if (symbol == "EURAUD") isymbol = 10; else if (symbol == "EURCAD") isymbol = 11; else if (symbol == "GBPUSD") isymbol = 12; else if (symbol == "GBPJPY") isymbol = 13; else if (symbol == "GBPCHF") isymbol = 14; else if (symbol == "GBPAUD") isymbol = 15; else if (symbol == "GBPCAD") isymbol = 16; else isymbol = 17; return (TicketNumber + isymbol); //return (StrToInteger(StringConcatenate(TicketNumber, isymbol, timeFrame))); }
Hi...
The GetTicketNumber function called to create TicketNumber based on symbol and timeframe..The code as below:-
hi..
what do you means ?
I have passed the TicketNumber on Ordersend command.. where is my mistake ?
... void OpenBuy() { if (MinProfit > 0) { OrderSend(Symbol(),OP_BUY,lot,Ask,1,0,Ask+MinProfit*Point,"arnab",TicketNumber,0,Blue); } else { OrderSend(Symbol(),OP_BUY,lot,Ask,1,0,0,"arnab",TicketNumber,0,Blue); } } ...
hi..
what do you means ?
I have passed the TicketNumber on Ordersend command.. where is my mistake ?
There is no variable in OrderSend for the ticket number, the ticket number is returned by OrderSend(). Read the documentation click ---> OrderSend()
What you are passing to OrderSend() is the Magic Number not the Ticket Number, they are very different.

- 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..
This is my code, when i test it, its always return false and execute OpenBuy function, why its happened please guide me :-