retcode=10021 comment='No prices'

 
>>> lot = 0.1
>>> point = mt5.symbol_info(symbol).point
>>> price = mt5.symbol_info_tick(symbol).ask
>>> point
1e-05
>>> price
77.057
>>> deviation = 20
>>> request = {
...     "action": mt5.TRADE_ACTION_DEAL,
...     "symbol": symbol,
...     "volume": lot,
...     "type": mt5.ORDER_TYPE_BUY,
...     "price": price,
...     "sl": price - 50000 * point,
...     "tp": price + 50000 * point,
...     "deviation": deviation,
...     "magic": 234000,
...     "comment": "python script open",
...     "type_time": mt5.ORDER_TIME_GTC,
...     "type_filling": mt5.ORDER_FILLING_RETURN,
... }
>>> request
{'action': 1, 'symbol': 'USDRUB', 'volume': 0.1, 'type': 0, 'price': 77.057, 'sl': 76.557, 'tp': 77.557, 'deviation': 20, 'magic': 234000, 'comment': 'python script open', 'type_time': 0, 'type_filling': 2}
>>>
>>> # send a trading request
>>> result = mt5.order_send(request)
>>> result
OrderSendResult(retcode=10021, deal=0, order=0, volume=0.0, price=0.0, bid=0.0, ask=0.0, comment='No prices', request_id=0, retcode_external=0, request=TradeRequest(action=1, magic=234000, order=0, symbol='USDRUB', volume=0.1, price=77.057, stoplimit=0.0, sl=76.557, tp=77.557, deviation=20, type=0, type_filling=2, type_time=0, expiration=0, comment='python script open', position=0, position_by=0))
>>>
>>>
 
Hi, I obtained this error on my script...Why?
 
Rob_Gent #:
Hi, I obtained this error on my script...Why?

did you try looking the result code up? 

 https://www.mql5.com/en/docs/constants/errorswarnings/enum_trade_return_codes

with this problem and your copy ticks problem - I would suggest that you are not connected to the servers correctly

Documentation on MQL5: Constants, Enumerations and Structures / Codes of Errors and Warnings / Trade Server Return Codes
Documentation on MQL5: Constants, Enumerations and Structures / Codes of Errors and Warnings / Trade Server Return Codes
  • www.mql5.com
Trade Server Return Codes - Codes of Errors and Warnings - Constants, Enumerations and Structures - MQL5 Reference - Reference on algorithmic/automated trading language for MetaTrader 5
 
Yes, i'm looking for 

10016

TRADE_RETCODE_INVALID_STOPS

Invalid stops in the request


and in the result of the script appear 'No prices'. I try to make some changes (stop loss, take profit...), but without success ... The code is correct, because it is in this official page 

https://www.mql5.com/en/docs/integration/python_metatrader5/mt5ordersend_py


I don't know how to do...

Documentation on MQL5: Integration / MetaTrader for Python / order_send
Documentation on MQL5: Integration / MetaTrader for Python / order_send
  • www.mql5.com
order_send - MetaTrader for Python - Integration - MQL5 Reference - Reference on algorithmic/automated trading language for MetaTrader 5
 
Rob_Gent #:
Yes, i'm looking for 

10016

TRADE_RETCODE_INVALID_STOPS

Invalid stops in the request


and in the result of the script appear 'No prices'. I try to make some changes (stop loss, take profit...), but without success ... The code is correct, because it is in this official page 

https://www.mql5.com/en/docs/integration/python_metatrader5/mt5ordersend_py


I don't know how to do...

That’s not the returned code
I gave you the link look it up
 
Excuse me, the error is 

10021

TRADE_RETCODE_PRICE_OFF

There are no quotes to process the request


but I don't understand the error, because there are the price, stop loss and take profit...The account is a new demo ( There are quotes to process the request ), and so I don't know where the error might be.

 
Rob_Gent:

Can you open it directly from MT5 ?

Which broker/server are you using ?

 
Rob_Gent:
...     "type_filling": mt5.ORDER_FILLING_RETURN,
Are you sure you can use that filling type ? It's not allowed with MARKET execution.
Documentation on MQL5: Constants, Enumerations and Structures / Environment State / Symbol Properties
Documentation on MQL5: Constants, Enumerations and Structures / Environment State / Symbol Properties
  • www.mql5.com
Symbol Properties - Environment State - Constants, Enumerations and Structures - MQL5 Reference - Reference on algorithmic/automated trading language for MetaTrader 5
 
I'm using server="MetaQuotes-Demo", I delete "type_filling": mt5.ORDER_FILLING_RETURN, and I only got the send request as a result once,
>>> point
1e-05
>>> price
1.13437
>>> deviation = 20
>>> request = {
...     "action": mt5.TRADE_ACTION_DEAL,
...     "symbol": symbol,
...     "volume": lot,
...     "type": mt5.ORDER_TYPE_BUY,
...     "price": price,
...     "sl": price - 50000 * point,
...     "tp": price + 50000 * point,
...     "deviation": deviation,
...     "magic": 234000,
...     "comment": "python script open",
...     "type_time": mt5.ORDER_TIME_GTC,
... }
>>> request
{'action': 1, 'symbol': 'EURUSD', 'volume': 0.01, 'type': 0, 'price': 1.13437, 'sl': 0.6343700000000001, 'tp': 1.63437, 'deviation': 20, 'magic': 234000, 'comment': 'python script open', 'type_time': 0}
>>>
>>> # send a trading request
>>> result = mt5.order_send(request)
>>> result
OrderSendResult(retcode=10021, deal=0, order=0, volume=0.0, price=0.0, bid=0.0, ask=0.0, comment='No prices', request_id=0, retcode_external=0, request=TradeRequest(action=1, magic=234000, order=0, symbol='EURUSD', volume=0.01, price=1.13437, stoplimit=0.0, sl=0.6343700000000001, tp=1.63437, deviation=20, type=0, type_filling=0, type_time=0, expiration=0, comment='python script open', position=0, position_by=0))
>>>
while all other of times the request is failed...
 
I get error

10021

TRADE_RETCODE_PRICE_OFF

There are no quotes to process the request

 
If I try with server="PepperstoneUK-Live", I get the following error: