Download MetaTrader 5

HistorySelect works not properly

To add comments, please log in or register
chinaski
890
chinaski  

Hello,

i still have problems to get HistorySelect properly.

Basically, HistorySelect does not return orders latest place. They can be seen in the history tab but are not reflected through History order list.

Find attached a simple EA proving this.

Simply open a position with BUY or SELL manually, raise, lower Position with BUY or SELL (market).

You will see: sooner or later latest orders are not print to expert log but can be seen in history tab.

Documentation on MQL5: Trade Functions / HistorySelect
  • www.mql5.com
Trade Functions / HistorySelect - Documentation on MQL5
Files:
Rashid Umarov
Admin
12055
Rashid Umarov  

Stop using this line in your EA (commented by me)

         if(current_string!=last_string)
           {
            last_string=current_string;
            Print(last_string);
           }
        }
     }
   //time_start=TimeCurrent();
//---

Because  it says for TimeCurrent

Returns the last known server time server, time of the last quote receipt for one of the symbols selected in the "Market Watch" window.

It means that this value can be changed while you EA reach the latest line and you can get such "tricks" with "missed" historical orders.

chinaski
890
chinaski  
Rosh:

Stop using this line in your EA (commented by me)

Because  it says for TimeCurrent

It means that this value can be changed while you EA reach the latest line and you can get such "tricks" with "missed" historical orders.

Hello Rosh,

first, thank you for answer.

I picked TimeCurrent from various samples. My intention is to get the very latest order included in this list.

So the question might be: What timestamp to use for TimeTo in function HistorySelect ? 

 

However, you suggestion does not solve this issue . You get a bunch of orders (on each call list size increases).

You can check this easily: Place some MKT orders, compare the experts debug out with ticket id shown in order (history) tab.

Sooner or later, you will miss a ticket id in experts debug out. 

 

I consider this a bug and would be happy if one of the MT5 staff could have look on this. Thank you. 

chinaski
890
chinaski  
chinaski:

Hello Rosh,

first, thank you for answer.

I picked TimeCurrent from various samples. My intention is to get the very latest order included in this list.

So the question might be: What timestamp to use for TimeTo in function HistorySelect ? 

 

However, you suggestion does not solve this issue . You get a bunch of orders (on each call list size increases).

You can check this easily: Place some MKT orders, compare the experts debug out with ticket id shown in order (history) tab.

Sooner or later, you will miss a ticket id in experts debug out. 

 

I consider this a bug and would be happy if one of the MT5 staff could have look on this. Thank you. 

Hello Rosh,

 "Stop using this line in your EA (commented by me)

Because  it says for TimeCurrent

It means that this value can be changed while you EA reach the latest line and you can get such "tricks" with "missed" historical orders."

 

This is no solution for my problem.You still miss sometimes or lets say often the very latest order. Please check it out.

Outcomment line and try it. You will see: order is listed in History Tab but not reflected through OrderHistory.

Thank you 

chinaski
890
chinaski  

To whom ever concern,  solution suggested above:

 

//time_start=TimeCurrent();

does not work. Still latest orders are not in HistoryList. Easy to test with script attached.

 

Also: the start time is not the problem. The endtime seems not to be something like "now". (related to last tick...why ?)


Rashid Umarov
Admin
12055
Rashid Umarov  

You can use TimeTradeServer() instead of TimeCurrent().

void scan_orders(void)
{
   datetime to=TimeTradeServer();
Try yourself to get what you need.
chinaski
890
chinaski  
Rosh:

You can use TimeTradeServer() instead of TimeCurrent().

Try yourself to get what you need.

Hello,

already done. Not save as well. Latest orders somtimes missed.

What i need is very simple: if there is a history order, i'd like to query it with HistorySelect with 100% success, not 70 %.

If you don't believe, please checkout my code. If you have a definite solution, i appreciate. Thank you. 

Rashid Umarov
Admin
12055
Rashid Umarov  
You should write to Servicedesk with all details if you are sure.
Get in touch with developers using Service Desk!
  • www.mql5.com
We therefore attach great importance to all user reports about issues in our programs and try to answer each one of them.
chinaski
890
chinaski  
Rosh:

You should write to Servicedesk with all details if you are sure.
thank you for this hint!
Gustavo Hennemann
165
Gustavo Hennemann  

Hi guys,

How this issue ended? There are a solution? I'm facing exactly the same problem!

Thanks

Alain Verleyen
Moderator
31477
Alain Verleyen  
Chuckero:

Hi guys,

How this issue ended? There are a solution? I'm facing exactly the same problem!

Thanks

Please show your code and explain how to reproduce the problem.
12
To add comments, please log in or register