[Python] MetaTrader 5 Manager API - PositionGet returns "Not found" error despite open...

Discussão em 'Python' iniciado por Stack, Maio 7, 2025.

  1. Stack

    Stack Membro Participativo

    I am working with the MT5Manager library to retrieve client positions in MetaTrader 5. However, despite verifying that the client exists and has an open position for the specified symbol, my request returns the error: (-1, <EnMTAPIRetcode.MT_RET_ERR_NOTFOUND: 13>, 'Not found')

    # Include the library
    import MT5Manager

    server = ""
    login =
    password = ""

    # Create the graphical interface
    manager = MT5Manager.ManagerAPI()

    # Connect to the server
    if manager.Connect(
    server=server,
    login=login,
    password=password,
    # pump_mode=MT5Manager.ManagerAPI.EnPumpModes.PUMP_MODE_USERS,
    timeout=120000
    ):
    # Get the client's position
    managers = manager.PositionGet(login=114714, symbol="eurusd.rw")
    print(managers)

    # Check the position
    if managers is not False:
    print(f"Opening price is {managers.PriceOpen}")
    else:
    # Failed to retrieve the position list
    print(f"Failed to get position: {MT5Manager.LastError()}")

    # Disconnect from the server
    manager.Disconnect()
    else:
    # Failed to connect to the server
    print(f"Failed to connect to the server: {MT5Manager.LastError()}")


    What I have tried:

    • Verified that the client exists with the correct login ID (114714).
    • Checked that there is an open position in eurusd.rw for this client.
    • Attempted to retrieve all positions using PositionGetAll(login=114714), but still does not return the expected data.
    • Confirmed the correct symbol format. Question: Why is PositionGet returning MT_RET_ERR_NOTFOUND, despite an active position existing for this client and symbol? Is there something missing or incorrect in my approach?

    Any help or suggestions would be greatly appreciated!

    Continue reading...

Compartilhe esta Página