MetaTrader5 Python Integration. (orders_get is empty (not None))

 

Hi, i have a problem with my code, it executes the order without any problem but when i try to use both orders_get() and orders_get(Symbol = "EURUSD") it returns an empty object.

Here is the code and the example (I can assure that there is an open position). 

CODE:

#sendOrder(mt5.TRADE_ACTION_DEAL, symbol , 0.01, mt5.ORDER_TYPE_BUY, ask,  ask - 100 * point,  ask + 100 * point, 20, 23400, "example", mt5.ORDER_TIME_GTC,  mt5.ORDER_FILLING_RETURN)
bid = mt5.symbol_info_tick(symbol).bid

request = {
    "action": mt5.TRADE_ACTION_DEAL,
    "symbol": "EURUSD",
    "volume": 0.01,
    "type": mt5.ORDER_TYPE_SELL,
    "price": bid,
    "sl": bid + 100 * point,
    "tp": bid - 100 * point,
    "deviation": 20,
    "magic": 234000,
    "comment": "python script open",
    "type_time": mt5.ORDER_TIME_GTC,
    "type_filling": mt5.ORDER_FILLING_RETURN,
}
print(mt5.order_send(request))

orders = mt5.orders_get(symbol="EURUSD")
print(orders)
print(mt5.orders_get())
if orders is None:
    print("No orders on EURUSD, error code={}".format(mt5.last_error()))
else:
    print("Total orders on EURUSD:",len(orders))
    for order in orders:
        print(order)

OUTPUT:

OrderSendResult(retcode=10009, deal=2177241905, order=2202475454, volume=0.01, price=1.11039, bid=1.11039, ask=1.1104, comment='Request executed', request_id=4106088556, retcode_external=0, request=TradeRequest(action=1, magic=234000, order=0, symbol='EURUSD', volume=0.01, price=1.11039, stoplimit=0.0, sl=1.1113899999999999, tp=1.10939, deviation=20, type=1, type_filling=2, type_time=0, expiration=0, comment='python script open', position=0, position_by=0))

()
()
Total orders on EURUSD: 0
Documentation on MQL5: Python Integration / orders_get
Documentation on MQL5: Python Integration / orders_get
  • www.mql5.com
orders_get - Python Integration - MQL5 Reference - Reference on algorithmic/automated trading language for MetaTrader 5
 
Solved, I should have used positions_get() to get opened positions. I'm going to leave this thread for the future maybe someone else get confused.