Problem solved by moving HistorySelect from OnInit to OnTick!!

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
My code is as follows:
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 also used this code in the beginning of the expert, which is not useful .