- Do not assume history has only closed orders.
Do not assume history is ordered by date, it's not.
Could EA Really Live By Order_History Alone? (ubzen) - MQL4 programming forum -
Using OrdersTotal (or OrdersHistoryTotal)
directly and/or no Magic number filtering on your
OrderSelect loop means your code is incompatible with every EA (including itself on other charts and manual trading.)
Symbol Doesn't equal Ordersymbol when another currency is added to another seperate chart . - MQL4 programming forum
MagicNumber: "Magic" Identifier of the Order - MQL4 Articles
William Roeder:
Do not assume history has only closed orders.
Do not assume history is ordered by date, it's not.
Could EA Really Live By Order_History Alone? (ubzen) - MQL4 programming forum
Do not assume history has only closed orders.
Do not assume history is ordered by date, it's not.
Could EA Really Live By Order_History Alone? (ubzen) - MQL4 programming forum
I am not assuming anything,I do realise I need a code for sequence and also that orderhistory includes open orders, that is fine I have counter measures for that,all I need is to translate the lines to MQL5.
I have tried replacing "OrdersHistoryTotal" with "HistoryOrdersTotal" but it does not work...
//--- request trade history HistorySelect(from_date,to_date); uint total_deals=HistoryDealsTotal(); ulong ticket_history_deal=0; //--- for all deals for(uint i=total_deals-1;i<total_deals;i++) { }^This is all I needed, Thanks for nothing.
Forum on trading, automated trading systems and testing trading strategies
OrderCloseTime Expert Advisor MQL5
fxsaber, 2018.07.06 00:49
#include <MT4Orders.mqh> // https://www.mql5.com/en/code/16006 void LastTimeMQL4( datetime &OpenTime, datetime &CloseTime ) { for (int i = OrdersHistoryTotal() - 1; i >= 0; i--) if (OrderSelect(i, SELECT_BY_POS, MODE_HISTORY) && (OrderType() <= OP_SELL)) { OpenTime = OrderOpenTime(); CloseTime = OrderCloseTime(); break; } } void LastTimeMQL5( datetime &OpenTime, datetime &CloseTime ) { if (HistorySelect(0, INT_MAX)) { for (int i = HistoryDealsTotal() - 1; i >= 0; i--) { const ulong Ticket = HistoryDealGetTicket(i); if (HistoryDealGetInteger(Ticket, DEAL_ENTRY) == DEAL_ENTRY_OUT) { CloseTime = (datetime)HistoryDealGetInteger(Ticket, DEAL_TIME); if (HistorySelectByPosition(HistoryDealGetInteger(Ticket, DEAL_POSITION_ID))) OpenTime = (datetime)HistoryDealGetInteger(HistoryDealGetTicket(0), DEAL_TIME); break; } } } }
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Good day I have been coding with mql4 and have recently had to change to a broker that uses mt5 only.
I have lines in mql4 that I dont know how to translate to mql5 language because my results are faulty.
Basically what this says is, if i have for example 5 closed positions in the history log arranged in order, the expert should select the latest one.
e.g (history log with positions)
875545 ---->SELECT THIS ORDER
875544
875543
875542
875541
Here are those lines please help
Please help. Thank you