hi guy i have a part of my code that i try to calla OrderType
but, 1 OrderType() not highlight and when i try to run give me error 'OrderType' - undeclared identifier PanelDialog.mqh 2111 37
but here exist https://www.mql5.com/en/docs/standardlibrary/tradeclasses/corderinfo/corderinfoordertype , oprobably because i call it in file .mqh ?
Try these , first select with the ticket , call mql4OrderSelect , then call mql4OrderType
//auto selection of pending history or live ulong SELECTED_TICKET=0; enum selected_type{ selected_empty=0,//empty selected_market=1,//live selected_market_history=2,//history selected_pending=3,//pending selected_pending_history=4//pending history }; selected_type SELECTED_TYPE=selected_empty; bool mql4OrderSelect(ulong ticket){ SELECTED_TICKET=0; SELECTED_TYPE=selected_empty; //live if(PositionSelectByTicket(ticket)){SELECTED_TICKET=ticket;SELECTED_TYPE=selected_market;return(true);} //pending if(OrderSelect(ticket)){SELECTED_TICKET=ticket;SELECTED_TYPE=selected_pending;return(true);} //market history if(HistorySelectByPosition(ticket)){SELECTED_TICKET=ticket;SELECTED_TYPE=selected_market_history;return(true);} //pending history if(HistoryOrderSelect(ticket)){SELECTED_TICKET=ticket;SELECTED_TYPE=selected_pending_history;return(true);} return(false); } //order type int mql4OrderType(){ if(SELECTED_TYPE!=selected_empty) { //market + market history if(SELECTED_TYPE==selected_market||SELECTED_TYPE==selected_market_history) { if(PositionGetInteger(POSITION_TYPE)==POSITION_TYPE_BUY){return(OP_BUY);} if(PositionGetInteger(POSITION_TYPE)==POSITION_TYPE_SELL){return(OP_SELL);} } //pending if(SELECTED_TYPE==selected_pending) { if(OrderGetInteger(ORDER_TYPE)==ORDER_TYPE_BUY_LIMIT){return(OP_BUYLIMIT);} if(OrderGetInteger(ORDER_TYPE)==ORDER_TYPE_BUY_STOP){return(OP_BUYSTOP);} if(OrderGetInteger(ORDER_TYPE)==ORDER_TYPE_SELL_LIMIT){return(OP_SELLLIMIT);} if(OrderGetInteger(ORDER_TYPE)==ORDER_TYPE_SELL_STOP){return(OP_SELLSTOP);} } //pending history if(SELECTED_TYPE==selected_pending_history) { if(HistoryOrderGetInteger(SELECTED_TICKET,ORDER_TYPE)==ORDER_TYPE_BUY_LIMIT){return(OP_BUYLIMIT);} if(HistoryOrderGetInteger(SELECTED_TICKET,ORDER_TYPE)==ORDER_TYPE_BUY_STOP){return(OP_BUYSTOP);} if(HistoryOrderGetInteger(SELECTED_TICKET,ORDER_TYPE)==ORDER_TYPE_SELL_LIMIT){return(OP_SELLLIMIT);} if(HistoryOrderGetInteger(SELECTED_TICKET,ORDER_TYPE)==ORDER_TYPE_SELL_STOP){return(OP_SELLSTOP);} } } return(NULL); }
and also define the mql4 operations somewhere :
#define OP_BUY 1 #define OP_SELL 2 #define OP_BUYLIMIT 3 #define OP_BUYSTOP 4 #define OP_SELLLIMIT 5 #define OP_SELLSTOP 6
Try these , first select with the ticket , call mql4OrderSelect , then call mql4OrderType
and also define the mql4 operations somewhe
thanks for solution , but i want know why if exist in manual possibility to call with
OrderType()in reality not work , is a bug of MT5 or is deprecated or i did do some mistake ?
MetaTrader 5 trade functionality is totally different to that of version 4. Please read the following to better understand it ...
Orders, Positions and Deals in MetaTrader 5
MetaQuotes, 2011.02.01 16:13
Creating a robust trading robot cannot be done without an understanding of the mechanisms of the MetaTrader 5 trading system. The client terminal receives the information about the positions, orders, and deals from the trading server. To handle this data properly using the MQL5, it's necessary to have a good understanding of the interaction between the MQL5-program and the client terminal.
- 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 guy i have a part of my code that i try to calla OrderType
but, 1 OrderType() not highlight and when i try to run give me error 'OrderType' - undeclared identifier PanelDialog.mqh 2111 37
but here exist https://www.mql5.com/en/docs/standardlibrary/tradeclasses/corderinfo/corderinfoordertype , oprobably because i call it in file .mqh ?