HistoryDeal functions don't work in Tester

 

My code is as follows:

     int count = HistoryDealsTotal();
     ulong tik = HistoryDealGetTicket(count-1);
     ENUM_DEAL_REASON drrr2 = HistoryDealGetInteger(tik1+1, DEAL_REASON);



When using the debugger (tester), values of variables is as follows, while they are different from the History table of deals.

watch window:


History table in tester:

As it is known, the number of  deals must be 2, which function (HistoryDealsTotal) returned 1 (count)!
Also, the reason for the deal with ticket 3 is the activation of SL, which the function( HistoryDealGetInteger(tik1+1, DEAL_REASON) ) returned its value incorrectly!  ( DEAL_REASON_CLIENT instead of  DEAL_REASON_SL )
I tried every DEAL_PROPERTY the results were still incorrect.


I also used this code in the beginning of the expert, which is not useful .
int OnInit()
  {
//---
HistorySelect(0, D'2024.01.01'); 
...
}
 
Problem solved by moving HistorySelect from OnInit to OnTick!!
Reason: