Download MetaTrader 5
To add comments, please log in or register
Publish your trading signal. Gain access to millions of traders!
Michael
525
Michael 2016.11.14 02:44 

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!   :)

JC
1453
JC 2016.11.14 11:33  
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. 

Carl Schreiber
6391
Carl Schreiber 2016.11.14 11:53  
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!
Alain Verleyen
Moderator
30295
Alain Verleyen 2016.11.14 13:25  
Carl Schreiber:
You should check and provide the error codes!
He did. It's error 3.
whroeder1
14236
whroeder1 2016.11.14 16:45  
  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
Michael
525
Michael 2016.11.16 00:06  

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

 

TimeCurrent()-OrderOpenTime()>5*60
/
To add comments, please log in or register