M1 EA Gives OrderSend Error 3

 

Hello everyone,

It's my first post here, I always get great advices on how to get the best for my EA here.
Today I was trying to create a m1 EA, while trying testing it, after downloading the data, it keeps telling me OrderSend error 3, but the fact is that I was trying the same exact EA on m5 and was working fine, now I'll try to send you guys the ordersend function:

// Entry Buy 2
   if(signal=="Buy 2" && (Ask - Bid <= 10*Point) && BullPower > 0 && BearPower > 0)
     {
      ticket = OrderSend(Symbol(),OP_BUYSTOP,AutoLotSize(),(Ask+(17*Point)),3,(Bid-(8*Point)),(Ask+(87*Point)),"Entry 2",5207418,0,clrGreen);
     }
   else
      if(ticket<0)
        {
         int lastError = GetLastError();
         HandleOrderSendError(lastError);
        }


// Entry Buy 3
   if(signal=="Buy 3" && (Ask - Bid <= 10*Point) && BullPower > 0 && BearPower > 0)
     {
      ticket = OrderSend(Symbol(),OP_BUYSTOP,AutoLotSize(),(Ask+(25*Point)),3,(Bid-(5*Point)),(Ask+(95*Point)),"Entry 3",5207418,0,clrGreen);
     }
   else
      if(ticket<0)
        {
         int lastError = GetLastError();
         HandleOrderSendError(lastError);
        }


// Entry sell 2
   if(signal=="Sell 2" && (Ask - Bid <= 10*Point) && BullPower < 0 && BearPower < 0)
     {
      ticket = OrderSend(Symbol(),OP_SELLSTOP,AutoLotSize(),(Bid-(17*Point)),3,(Ask+(8*Point)),(Bid-(87*Point)),"Entry 2",5207418,0,clrRed);
     }
   else
      if(ticket<0)
        {
         int lastError = GetLastError();
         HandleOrderSendError(lastError);
        }


// Entry sell 3
   if(signal=="Sell 3" && (Ask - Bid <= 10*Point) && BullPower < 0 && BearPower < 0)
     {
      ticket = OrderSend(Symbol(),OP_SELLSTOP,AutoLotSize(),(Bid-(25*Point)),3,(Ask+(5*Point)),(Bid-(95*Point)),"Entry 3",5207418,0,clrRed);
     }
   else
      if(ticket<0)
        {
         int lastError = GetLastError();
         HandleOrderSendError(lastError);
        }

But I don't understand why there are mistakes.

if someone could help me I'll be grateful.

Thanks a lot in advance!

 

Have you looked up what Error 3 means? Where (which line) does it happen?

I suggest you to use the debugger and check the rules for opening a position:


 

Appreciate your table, thanks a lot.

The thing is that, since I had this EA working on m5, it had no issues at all, no strange messages and no other problems, so what I was thinking is that maybe m1 could be the problem, but why?
I was looking online and I couldn't find anything for my specific problem, I think I should start printing everything but even there understanding where the issue is might be confusing.

Any other solution I can have? I started the debug but it's the first time I'm using it

 
I found the solution! I really appreciate you, thanks to your table I could find the mistake I was made! Thanks a lot Carl!!
 
TwinsMillionaires: M1 EA Gives OrderSend Error 3
      ticket = OrderSend(Symbol(),OP_BUYSTOP,AutoLotSize(),(Ask+(17*Point)),3,(Bid-(8*Point)),(Ask+(87*Point)),"Entry 2",5207418,0,clrGreen);
  1. Why did you post your MT4 question in the MT5 General section instead of the MQL4 section, (bottom of the Root page)?
              General rules and best pratices of the Forum. - General - MQL5 programming forum? (2017)
    Next time, post in the correct place. The moderators will likely move this thread there soon.


  2. There is no need to create pending orders in code.

    1. The pending has the slight advantage, A) you are closer to the top of the queue (filled quicker), B) there's no round trip network delay (filled quicker.)

      Don't worry about it unless you're scalping M1 or trading news.

    2. Humans can't watch the screen 24/7, so they use pending orders; EAs can, so no need for pending orders, have it wait until the market reaches the trigger price and just open an order.