So, changing the request to make it similar to the one made in the documentation ( https://www.mql5.com/en/docs/constants/tradingconstants/enum_trade_request_actions#trade_action_pending) made it work.
void QuestionFunction() { ZeroMemory(request); ZeroMemory(result); request.action = TRADE_ACTION_PENDING; request.symbol = Symbol(); request.volume = myVol; request.deviation = 2; double price; double point = SymbolInfoDouble(_Symbol, SYMBOL_POINT); int digits = SymbolInfoInteger(_Symbol, SYMBOL_DIGITS); request.type = ORDER_TYPE_SELL_STOP; price = SymbolInfoDouble(Symbol(), SYMBOL_BID) - 200 * point; request.price = NormalizeDouble(price,digits); myTicket = SendTradeRequest(); }
I don't really understand why though.
Documentation on MQL5: Constants, Enumerations and Structures / Trade Constants / Trade Operation Types
- www.mql5.com
Trade Operation Types - Trade Constants - Constants, Enumerations and Structures - MQL5 Reference - Reference on algorithmic/automated trading language for MetaTrader 5
absconditus87 #:
Because now it knows on which symbol to place the pending order.
So, changing the request to make it similar to the one made in the documentation ( https://www.mql5.com/en/docs/constants/tradingconstants/enum_trade_request_actions#trade_action_pending) made it work.
I don't really understand why though.
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
Here's my code
But when I place such an order manually, i.e. a sell stop on EURUSD that is 0.002 below the the bid, it goes through and gets filled.
I'm using a MetaQuotes demo account.
Thank you.