Download MetaTrader 5

Multiple Data Types in Multi Dimensional Array

To add comments, please log in or register
wieb
118
wieb  
    int orderstotal = OrdersTotal();
    int orders = 0;
    int ordticket[30][2];
    ArrayResize(ordticket,30,30); 
    for (int i = 0; i < orderstotal; i++)
    {
        if(OrderSelect(i, SELECT_BY_POS, MODE_TRADES)==true){
        if (OrderType() != OP_BUY || OrderSymbol() != Symbol() || OrderMagicNumber() != MagicX)
        {
            continue;
        }
        ordticket[orders][0] = OrderOpenTime();
        ordticket[orders][1] = OrderTicket();
        orders++;
        }
    }

//Possible loss of data due to type conversion:  ordticket[orders][0] = OrderOpenTime()

How to solve "Possible loss of data due to type conversion"?

T‌hanks for the help.

Keith Watford
Moderator
10533
Keith Watford  
ordticket[orders][0] = (int)OrderOpenTime()


wieb
118
wieb  
Keith Watford:
ordticket[orders][0] = (int)OrderOpenTime()



Thank you, it solved the issue.
honest_knave
Moderator
2342
honest_knave  

If you are using multiple data types in an array, you may want to explore structures.

Structures, Classes and Interfaces - Data Types - Language Basics - MQL4 Reference
Structures, Classes and Interfaces - Data Types - Language Basics - MQL4 Reference
  • docs.mql4.com
Structures, Classes and Interfaces - Data Types - Language Basics - MQL4 Reference
whroeder1
17093
whroeder1  
Yep, use a single dimension array of a structure. See Sort multiple arrays - MQL4 and MetaTrader 4 - MQL4 programming forum
To add comments, please log in or register