When I make a get_position I have the list of my positions opened, and I have a colum with the "type".
Type 0 is a Buy position and Type 1 is a sell position.
positions=mt5.positions_get(symbol="GOLDmicro")
if positions==None:
print("No position on Gold, error code={}".format(mt5.last_error()))
elif len(positions)>0:
print("GOLD positions =",len(positions))
# Show all open positions
for position in positions:
print(position)
Allow the use of cookies to log in to the MQL5.com website.
Please enable the necessary setting in your browser, otherwise you will not be able to log in.
You are signed in. Two-factor authentication has been disabled. Set it up again and scan a new QR code, or continue with two-factor authentication disabled.
Hello,
When I make a get_position I have the list of my positions opened, and I have a colum with the "type".
Type 0 is a Buy position and Type 1 is a sell position.
The result looks like this:
TradePosition(ticket=542919563, time=1653651234, time_msc=1653651234856, time_update=1653651234, time_update_msc=1653651234856, type=0, magic=234000, identifier=542919563, reason=3,
volume=0.1, price_open=1859.44, sl=0.0, tp=1862.44, price_current=1859.35, swap=0.0, profit=-0.01, symbol='GOLDmicro', comment='TP0', external_id='')
How can I retrieve the type=0 to use it after?
I want after that something like this but I want to add the "type of position".
Someone got an idea?