Converting MQL4 trade functions to MQL5

 

Hi,

I've programmed MQL5 for a while but don't know much about MQL4 and I need to convert some MQL4 code with trade function to work with MQL5. 

As far as I can see, MQL4 deals with both positions/orders with the same functions, whilst MQL5 has separate functions for positions/orders.

For example, am I correct in assuming that to convert the trade function in the MQL4 example code below, I'd need to separate it out and use Positionxxx for BUY/SELL and Orderxxx for SELLSTOP/BUYSTOP?

Thanks

for(int Counter = 0; Counter <= OrdersTotal() - 1; Counter++) {
      if(OrderSelect(Counter, SELECT_BY_POS)) {
         if(OrderMagicNumber() == MagicNumber && OrderSymbol() == _Symbol && (OrderType() == OP_BUY || OrderType() == OP_SELL)) {
            open_orders++;
            if(OrderLots() > largest_lots) {
               ticket = OrderTicket();
               largest_lots = OrderLots();
            }
         }
         if(OrderMagicNumber() == MagicNumber && OrderSymbol() == _Symbol && OrderType() == OP_BUYSTOP) {
            gBuyStopTicket = OrderTicket();
            stopTicket = gBuyStopTicket;
         }
         else if(OrderMagicNumber() == MagicNumber && OrderSymbol() == _Symbol && OrderType() == OP_SELLSTOP) {
            gSellStopTicket = OrderTicket();
            stopTicket = gSellStopTicket;
         }
      }
   }
 
ceejay1962: I've programmed MQL5 for a while but don't know much about MQL4 a

MT4, orders are pending or opened. MT5, opened orders are positions. Do a position loop, and read the results.
MT5: first select a position via CPositionInfo, directly, or by 'MT4Orders' library (2016)

MT5 OrderType equivalent.
          OrderType() Functionality in MQL5 - General - MQL5 programming forum #1 (2022)

 
William Roeder #:

MT4, orders are pending or opened. MT5, opened orders are positions. Do a position loop, and read the results.
MT5: first select a position via CPositionInfo, directly, or by 'MT4Orders' library (2016)

MT5 OrderType equivalent.
          OrderType() Functionality in MQL5 - General - MQL5 programming forum #1 (2022)

Thanks for the links, much appreciated.