Can anybody please give a code hint
how to write in MQL5 that was OrderClose() and OrderDelete() in MQL4?
Please no OOP.
Thanks a lot."
#include <Trade\Trade.mqh>
..............
CTrade trade;
COrderInfo order;
CPositionInfo position;
// deleting pending orders
for( int i = OrdersTotal() -1; i >= 0; i--)
{
if( order.Select( OrderGetTicket( i) )
{
if( order.Symbol() == your_symbol)
{
........
if( trade.OrderDelete( order.Ticket() ) )
{
// ok, the order was deleted
}
else
{
// order was not deleted
}
}
}
//closing buy or sell positions
((first order determines if a buy or sell position)
if( position.Select( your_symbol) )
{
if( trade.PositionClose( your_symbol) )
{
//ok, position is closed
}
else
{
//position wasn't closed
}
}
..........
....
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Can anybody please give a code hint
how to write in MQL5 that was OrderClose() and OrderDelete() in MQL4?
Please no OOP.
Thanks a lot.