I was able to send the order... The final request:
But all orders, as soon as they reach MT5, they are automatically canceled. I talked with the broker company and they are saying that they are not cancelling it. It is the app MT5 that is cancelling. Any idea if it is being cancelled by some wrong or missing parameter?
request = {
'action': mt5.TRADE_ACTION_PENDING,
'symbol': [stock symbol],
'price': [price],
'sl': [stop loss value],
'tp': [take profit value],
'type': mt5.ORDER_TYPE_BUY_LIMIT,
'volume': [total volume],
'type_time': mt5.ORDER_TIME_SPECIFIED_DAY,
'expiration': int((datetime.now(timezone.utc) + timedelta(days=7)).timestamp()),
'type_filling': mt5.ORDER_FILLING_IOC,
'comment': 'comment xxx'
}
But all orders, as soon as they reach MT5, they are automatically canceled. I talked with the broker company and they are saying that they are not cancelling it. It is the app MT5 that is cancelling. Any idea if it is being cancelled by some wrong or missing parameter?
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
}
No matter what I try, i am receiving the error "Invalid expiration (10022)". I tried some different ways to set that date, just like:
'time_expires': datetime.now(timezone.utc) + timedelta(days=7),
import datetime as dt
expire = dt.datetime.now() + dt.timedelta(delta)
timestamp = int(expire.timestamp())
'time_expires': expiration_time(7),
'time_expires': int(datetime(2024, 2, 28, 13, 30, 0).timestamp()),
Any ideia what´s wrong? Is it something related to the structure of the request? Or the format of the time expired field? The reason why I am asking it is because my orders are being cancelled by MT5 automatically. I was checking some possible reasons and workarounds and I saw something about setting an expiration. I am trying to test it, but with no success.
Thanks in advance!