Invalid trade parameters (Errorcode 3)
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! :)
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.
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! :)
- 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.
- book.mql4.com
Thanks everyone. Found out it was the expiry. Nothing under 11 minutes allowed. So, going to do that manually.
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! :)