Your topic has been moved to the section: Expert Advisors and Automated Trading
Please consider which section is most appropriate — https://www.mql5.com/en/forum/172166/page6#comment_49114893
Please consider which section is most appropriate — https://www.mql5.com/en/forum/172166/page6#comment_49114893
Ok, a bit more of light. I discovered that I can get the last error adjusting the code like this:
result = self.mt5.order_send(request) if result is None: self.logger.print('error raised:') self.logger.print(self.mt5.last_error()) elif result.retcode != mt5.TRADE_RETCODE_DONE: self.handle_error(result)
This is my request. Action is mt5.TRADE_ACTION_MODIFY and type is mt5.ORDER_TYPE_BUY_STOP. What I´m doing is adjusting the entry price of the pending order
{'action': 7, 'order': 150046483026, 'price': 1.08311, 'type': 4}
and this is the error raised:
(-2, 'Invalid "order" argument')
I don´t know the meaning of that right now.
When I run the order_check and the order_send from Jupyter it works:
{'action': 7, 'order': 150046483026, 'price': 1.08176, 'type': 4} OrderCheckResult(retcode=0, balance=0.0, equity=0.0, profit=0.0, margin=0.0, margin_free=0.0, margin_level=0.0, comment='Done', request=TradeRequest(action=7, magic=0, order=150046483026, symbol='', volume=0.0, price=1.08176, stoplimit=0.0, sl=0.0, tp=0.0, deviation=0, type=4, type_filling=0, type_time=0, expiration=0, comment='', position=0, position_by=0)) OrderSendResult(retcode=10009, deal=0, order=150046483026, volume=0.0, price=0.0, bid=0.0, ask=0.0, comment='Request executed', request_id=3864266011, retcode_external=0, request=TradeRequest(action=7, magic=0, order=150046483026, symbol='', volume=0.0, price=1.08176, stoplimit=0.0, sl=0.0, tp=0.0, deviation=0, type=4, type_filling=0, type_time=0, expiration=0, comment='', position=0, position_by=0))

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
Pure Python 3.9 using the Metatrader5 library.
I can create market orders and pending orders from Script, but I can´t modify the price of a pending order. What is weird is that I actually can do that from a Jupyter notebook. From my script all I get is None as result. No error code and that is what is driving my nuts. Is there any way to enable any extra log so that I can see why from the script it doesn´t like it?
I repeat, I can create a pending order from the code, but when I try to modify it to "trail" de entry price it does nothing. Not even error code.
I leave the code below, just in case, I´ve have commented and uncommented the options many times to try different combinations.