Invalid trade parameters (Errorcode 3)

 

I'm not sure why, but here's the code:

   double myLot=1.07;
   int Ticket=OrderSend(Symbol(),
                        OP_SELLSTOP,
                        myLot,
                        NormalizeDouble(Close[1]-(30*_Point),_Digits),
                        0,
                        NormalizeDouble(High[1],_Digits),
                        NormalizeDouble(Bid-(400*_Point),_Digits),
                        "I hope this works",
                        12345,
                        Time[0]+(5*60),
                        clrRed);
   Print("ErrorCode:",GetLastError());

 Anyone got any ideas?  I'm old, so if it's something simple; give me break!   :)

 
Michael:

I'm not sure why, but here's the code:

   double myLot=1.07;
   int Ticket=OrderSend(Symbol(),
                        OP_SELLSTOP,
                        myLot,
                        NormalizeDouble(Close[1]-(30*_Point),_Digits),
                        0,
                        NormalizeDouble(High[1],_Digits),
                        NormalizeDouble(Bid-(400*_Point),_Digits),
                        "I hope this works",
                        12345,
                        Time[0]+(5*60),
                        clrRed);
   Print("ErrorCode:",GetLastError());

 Anyone got any ideas?  I'm old, so if it's something simple; give me break!   :)

It could be a number of things - e.g. 1.07 being an invalid lot size because the broker has a minimum increment of 0.10 - but it is most likely to be the expiration.

The rules in MT4 are strange and, as far as I am aware, not formally documented. But the minimum expiry is about 10 minutes, rather than the 5 you are trying to use. 

 
Michael:

I'm not sure why, but here's the code:

   double myLot=1.07;
   int Ticket=OrderSend(Symbol(),
                        OP_SELLSTOP,
                        myLot,
                        NormalizeDouble(Close[1]-(30*_Point),_Digits),
                        0,
                        NormalizeDouble(High[1],_Digits),
                        NormalizeDouble(Bid-(400*_Point),_Digits),
                        "I hope this works",
                        12345,
                        Time[0]+(5*60),
                        clrRed);
   Print("ErrorCode:",GetLastError());

 Anyone got any ideas?  I'm old, so if it's something simple; give me break!   :)

You should check and provide the error codes!
 
Carl Schreiber:
You should check and provide the error codes!
He did. It's error 3.
 
  1. Trying to open 30 points down. Check Requirements and Limitations in Making Trades - Appendixes - MQL4 Tutorial  What is MODE_STOPLEVEL?
  2. Normalizing lots, price:
    Do NOT use NormalizeDouble, EVER. For ANY Reason. It's a kludge, don't use it. It's use is always wrong
  3. Minimum expiration or expirations not supported by the broker.
  4. When I tried to use pending order, it seemed like the TP/SL was being compared to current market, not pending price. Try opening first and then set stops.
  5. Why use a expiration and/or stops/limits at all. Humans can't watch the screen 24/7 so they use pending orders; EA's can, so no need for pending orders, have it wait until the market reaches the trigger price and open an order.
Requirements and Limitations in Making Trades - Appendixes - MQL4 Tutorial
Requirements and Limitations in Making Trades - Appendixes - MQL4 Tutorial
  • book.mql4.com
Requirements and Limitations in Making Trades - Appendixes - MQL4 Tutorial
 

Thanks everyone.  Found out it was the expiry.  Nothing under 11 minutes allowed.  So, going to do that manually. 

 

TimeCurrent()-OrderOpenTime()>5*60
Reason: