Errors, bugs, questions - page 2943

 
How in MQL, without resorting to WinAPI, how can I know if the terminal has user focus (i.e. the user has an active window)? Now some functions, such as reading keyboard state (like TerminalInfoInteger(TERMINAL_KEYSTATE_CAPSLOCK)) return different values depending on activity of the window with the same keyboard state. This is a bummer.
 
Alexandr Sokolov:

MT5 build 2755

The terminal does not count all the ticks

Why did you draw such a conclusion?

 
Alexandr Sokolov:

MT5 build 2755

Terminal does not count all ticks



Try it like this

datetime st = 0;
int tics = 0;

//------------------------------------------------------------------

int OnCalculate(const int rates_total,
                const int prev_calculated,
                const datetime &time[],
                const double &open[],
                const double &high[],
                const double &low[],
                const double &close[],
                const long &tick_volume[],
                const long &volume[],
                const int &spread[])
  {
   
   if(prev_calculated == 0)
{
 ArraySetAsSeries(time,true);
 ArraySetAsSeries(tick_volume,true);
 st = time[0];
}   
   else if(time[0] != st)
     {
      tics++;
      Alert("T - ",tics," TV - ",tick_volume[0]);
     };
   
  //-----------------------------------------------------------------
   return(rates_total);
  }
 
Renat Fatkhullin:

Why did you draw this conclusion?

Because as I noticed OnCalculate is called when Ask and Bid prices change, but tick_volume[] only counts Bid changes

 

The following problem: I had an Expert Advisor on a netting account, it was opening and closing positions, I added a contract manually to the position opened by the robot and after a while the Expert Advisor's log showed errors:

Error when opening a position: 4753 - Position not found

The most interesting thing is that the position is closed, auto-tradingis disabled and EA is deleted from chart, but errors keep appearing.


 
Alexandr Sokolov:

Because I noticed that OnCalculate is called at Ask and Bid price changes, but tick_volume[] only counts Bid changes

OnTick is called at any change of price and not only (the terminal may require recalculate on many occasions such as additional data download or redistribution of historical data sets).

Tick volume, as well as the chart, is based on the change of bid price. On exchange execution, a separate real volume counter, where all buying and selling transactions are accounted for, is used.

 
Sayberix:

The following problem: I had an Expert Advisor on a netting account, it was opening and closing positions, I added a contract manually to the position opened by the robot and after a while the Expert Advisor's log showed errors:

Error when opening a position: 4753 - Position not found

The most interesting thing is that the position is closed, auto-tradingis disabled and the Expert Advisor is deleted from the chart.


This depends on the logic of the Expert Advisor.

It can remember and think only about its own operations and your manual intervention can spoil the logic of the Expert Advisor.

 
Renat Fatkhullin:

It depends on the logic of the EA itself.

It can only remember and think about its own operations and your manual intervention can mess up the Expert Advisor's logic.

I understand, but why has this error remained in the terminal? I told you that all positions are closed, auto-trading is disabled, the Expert Advisor is unloaded and even the terminal was restarted!

 
K-meleon browser does not reflect text in private messages(see screenshot). Hurtful, though! Somehow only in private. The browser is the easiest and fastest, but not widespread and Moz missing a font? Help who knows. The hardware is old and heavy browsers poorly pulls.
Files:
 
Sayberix:

I understand, but why has this error remained in the terminal? I told you that all positions are closed, auto-trading is off, the Expert Advisor is unloaded and I even restarted the terminal!

Miracles do not happen. Your Expert Advisor is running on one of the charts.