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());
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:
You should check and provide the error codes!
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());
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! :)
He did. It's error 3.
- Trying to open 30 points down. Check Requirements and Limitations in Making Trades - Appendixes - MQL4 Tutorial What is MODE_STOPLEVEL?
- 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
- SL/TP (stops) need to be normalized to tick size (not Point.) (On 5Digit Broker Stops are only allowed to be placed on full pip values. How to find out in mql? - MQL4 forum) and abide by the limits Requirements and Limitations in Making Trades - Appendixes - MQL4 Tutorial and that requires understanding floating point equality Can price != price ? - MQL4 forum
- Open price for pending orders need to be adjusted. On Currencies, Point == TickSize, so you will get the same answer, but it won't work on Metals. So do it right: Trailing Bar Entry EA - MQL4 forum or Bid/Ask: (No Need) to use NormalizeDouble in OrderSend - MQL4 forum
- Lot size must also be adjusted to a multiple of LotStep. If that is not a power of 1/10 then NormalizeDouble is wrong. Do it right.
- Minimum expiration or expirations not supported by the broker.
- 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.
- 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
- 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

You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
I'm not sure why, but here's the code:
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! :)