Print your error code when ticket <= 0
{
PrintFormat("FAILED %s %.2f price=%.8f stop=%.8f target=%.8f ERROR:%i",(operation == OP_SELL ? "SELL" : "BUY"),lots,price,stop,target,GetLastError());
}
Your 138 might be arising somewhere else.
----
[ Moved to MQL4 section ]
Print your error code when ticket <= 0
{
PrintFormat("FAILED %s %.2f price=%.8f stop=%.8f target=%.8f ERROR:%i",(operation == OP_SELL ? "SELL" : "BUY"),lots,price,stop,target,GetLastError());
}
Your 138 might be arising somewhere else.
----
[ Moved to MQL4 section ]
Hello,
how do you mean, please ? The order has not been placed.
What is the secret to get information why it has not been placed.
Do you know the secret undocumented hidden path that could save my time in order to get something run that simply should run ?
Thank you
Hello,
how do you mean, please ? The order has not been placed.
What is the secret to get information why it has not been placed.
Do you know the secret undocumented hidden path that could save my time in order to get something run that simply should run ?
Thank you
From the OrderSend() documentation:
Returned value
Returns number of the ticket assigned to the order by the trade server or -1 if it fails. To get additional error information, one has to call the GetLastError() function.
So, you attempt to send the order.
If you get -1, the OrderSend() failed. Checking GetLastError() will tell you why it failed.
PS I've never actually seen a ticket #0, but in theory it could happen. Your code should read:
if(ticket < 0)
- docs.mql4.com
Hello,
how do you mean, please ? The order has not been placed.
What is the secret to get information why it has not been placed.
Do you know the secret undocumented hidden path that could save my time in order to get something run that simply should run ?
Thank you
Also, error 138 is a "Requote" error!...
ResetLastError();
int ticket = OrderSend( _Symbol, operation, lots, price, 50, stop, target, "", 0, 0, clrRed );
if(ticket <= 0)
{
PrintFormat( "FAILED %s %.2f price=%.8f stop=%.8f target=%.8f ERROR:%i",
(operation == OP_SELL ? "SELL" : "BUY"), lots, price, stop, target, _LastError );
}
else
Print( "HURRA" );
...
From the OrderSend() documentation:
So, you attempt to send the order.
If you get -1, the OrderSend() failed. Checking GetLastError() will tell you why it failed.
PS I've never actually seen a ticket #0, but in theory it could happen. Your code should read:
if(ticket < 0)
Please don't reply. You replies are no help, Sir.
I get error 138 ok and my question was why ? So you don't know and i ask you, do not answer because the next who has the problem
needs to read all your useless answers.
Thank you for your understanding,
Please don't reply. You replies are no help, Sir.
I get error 138 ok and my question was why ? So you don't know and i ask you, do not answer because the next who has the problem
needs to read all your useless answers.
Thank you for your understanding,
Please don't reply. You replies are no help, Sir.
I get error 138 ok and my question was why ? So you don't know and i ask you, do not answer because the next who has the problem
needs to read all your useless answers.
Thank you for your understanding,
So, I will reiterate the same words as @honest_knave. Good luck, and I will add too, Good Riddance!
Ok, from Carreiro
2 usefull comments.
1. Clear error state before calling OrderSend -> ResetLastError();
2. Error #138 is a requote error
Thank you for that.
So that makes sense. The #138 was triggered by calling RefreshRates().
As honest_knave said:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hello,
in backtest i get this order error 138.
This is my code.
MqlTick tick;
if(SymbolInfoTick(_Symbol,tick) == true)
{
double xbid = tick.bid;
double xask = tick.ask;
double point=SymbolInfoDouble(_Symbol,SYMBOL_POINT);
int operation=OP_BUY;
double price=xask;
double target=price + 100 * point;
double stop=price - 100 * point;
double lots=0.01;
int ticket=OrderSend( _Symbol,operation,lots,price,50,stop,target,"",0,0,clrRed);
if(ticket <= 0)
{
PrintFormat("FAILED %s %.2f price=%.8f stop=%.8f target=%.8f",(operation == OP_SELL ? "SELL" : "BUY"),lots,price,stop,target);
}
else
Print("HURRA");
}
else
{
Print("#ERROR SymbolInfoTick");
}
What is wrong ? Thank you.