Error -1

 

What is Error -1

When i try to send an order in gold sometimes i get -1 error and sometimes it is executed.

Any help?? 

 

This is the code i am using to send a buy

void OpenBY()
{
   int li_0;
   if(!IsTradeContextBusy())
   {
      li_0 = OrderSend(Symbol(), OP_BUY, Lots, Ask, Slipage, 0, Ask+TakeProfit*Point, Comments, Magic, 0, Red);
      if(GetLastError() != 0)
         {
            Alert("Last Error is ",li_0);
            Sleep(10000);
            OpenBY();
         }
   }
} 
 
scorpion007net:

What is Error -1

When i try to send an order in gold sometimes i get -1 error and sometimes it is executed.

Any help?? 

 

This is the code i am using to send a buy

Don't check for an error when there is not.

There is only an error when Ordersend returns -1 :

Returned value

Returns number of the ticket assigned to the order by the trade server or -1 if it fails.
 
int li_0;
Decompiled code is stolen code. Either you are a thief, a fence, or the receiver of stolen (intellectual) property. Either way we will not be an accomplice after the fact to theft. See also https://www.mql5.com/en/forum/134317
 
WHRoeder:
Decompiled code is stolen code. Either you are a thief, a fence, or the receiver of stolen (intellectual) property. Either way we will not be an accomplice after the fact to theft. See also https://www.mql5.com/en/forum/134317

This is not a stolen code.

I am a mql4 coder for the last 4 years. 

I am coding this EA.. 

 
WHRoeder:
Decompiled code is stolen code. Either you are a thief, a fence, or the receiver of stolen (intellectual) property. Either way we will not be an accomplice after the fact to theft. See also https://www.mql5.com/en/forum/134317
It's a little light to say it's decompiled code.
Reason: