Mq4 and mq5 aren't compatible!
Here you can find info what to do:
https://www.mql5.com/en/articles/81
https://www.mql5.com/en/docs/migration
more of it with Google search for: site:mql5.com migration mq4 to mq5
- www.mql5.com
Hi, I'm trying to migrate an expert from mql4 to mql5, but I can't get the ticket of the new position that just opened.
In mql4, OrderSend() will return the ticket automiticly, but in mql5, trade.mqh m_trade.Buy only return true or false.
Please help me about how to get the ticket of position that opened by trade.mqh function?
Thanks!
You can use PositionSelectByTicket(ticket)
Hi, I'm trying to migrate an expert from mql4 to mql5, but I can't get the ticket of the new position that just opened.
In mql4, OrderSend() will return the ticket automiticly, but in mql5, trade.mqh m_trade.Buy only return true or false.
Please help me about how to get the ticket of position that opened by trade.mqh function?
Thanks!
#include <Trade\Trade.mqh> #include <Trade\PositionInfo.mqh> CTrade trade; CPositionInfo m_position; //open position trade.Sell(0.1,NULL,0,0,0,NULL); //Get position Ticket ulong ticket = trade.ResultOrder();
Please help me about how to get the ticket of position that opened by trade.mqh function?
If you use the search, you can quickly find the answer yourself.
Forum on trading, automated trading systems and testing trading strategies
Vladimir Karputov, 2022.03.26 07:15
Use ResultOrder
trade.ResultOrder()
Forum on trading, automated trading systems and testing trading strategies
Fernando Carreiro, 2023.02.10 16:48
// The code below is uncheck and will not compile. It is only an sample code. ulong posTicket = 0; int OnInit( void ) { posTicket = 0; }; void OnTick( void ) { if( posTicket == 0 ) { if( trade.Sell( lot_size, _Symbol ) ) { posTicket = trade.ResultOrder(); Print( "Sell order placed with ticket number = ", posTicket ); } else Print( "Sell order failed!" ); }; };
...
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hi, I'm trying to migrate an expert from mql4 to mql5, but I can't get the ticket of the new position that just opened.
In mql4, OrderSend() will return the ticket automiticly, but in mql5, trade.mqh m_trade.Buy only return true or false.
Please help me about how to get the ticket of position that opened by trade.mqh function?
Thanks!