Features of the mql5 language, subtleties and tricks - page 239

 
fxsaber #:

SymbolInfoTick.

I tried this option. Unfortunately, it does not work. If a symbol is added to the [Market Watch] window for the first time, there is no data on it yet and SymbolInfoTick returns null values.

I've also tested the CopyXXX functions, but they don't have a timeout and the process of waiting for data from the server lasts about 45 seconds, which is too long.

Need a quick way to find out if a character is unusable. I am referring to cases like this:


//---

Such symbols don't have data on the server and need a way to identify them so that they are not added to the [Market Overview] window or removed from the list if they are.

P.S. Perhaps there is some way to remove the lock on removing symbols from the list in the[ Market Watch] window?

 
Anatoli Kazharski #:

I tried that option. Unfortunately, it does not work. If a symbol is added to the [Market Watch] window for the first time, there is no data on it yet and SymbolInfoTick returns null values.

It is easy to get working symbols by hand.

  1. Add all symbols to the Market Watch in a couple of clicks.
  2. In a couple of seconds ticks on them will be received.
  3. Sorting by time with one mouse click.
  4. Deleting one of the tails of the obtained list using the Del key.
All this will take up to half a minute.
 
Anatoli Kazharski #:

I tried that option. Unfortunately, it does not work. If a symbol is added to the [Market Watch] window for the first time, there is no data on it yet and SymbolInfoTick returns null values.

I also tested the CopyXXX functions, but they have no timeout and the process of waiting for data from the server lasts about 45 seconds, which is too long.

Need a quick way to find out if a character is unusable. I am referring to cases like this:


//---

Such symbols have no data on the server and need a way to identify them so that they are not added to the [Market Watch] window or removed from the list if they are.

P.S. Perhaps there is some way to remove the lock on removing symbols from the list in the[Market Watch] window?

I've been fighting with this for about 6 years and I ask the developers to put things in order here.

Unfortunately, this problem has not been solved, and at the moment there are situations when the terminal hangs when anyone accesses a financial instrument for the first time.

 
Anatoli Kazharski #:

How can I find out if a symbol has data, so that I don't leave it in the [Market Watch] window if it doesn't?

I use such a check in a loop:

But after that I cannot manually remove symbols from the [Market Watch] window either one by one or all at once, while the Expert Advisor is on the chart:


Try checking the time of the last quote.

SymbolInfoInteger(name, SYMBOL_TIME);

If 0, there is no data.

I just checked by open charts.

2024.01.05 10:38:43.783 !00 (GBPUSD,H1) USDCAD 2024.01.05 09:38:51
2024.01.05 10:38:43.783 !00 (GBPUSD,H1) NZDUSD 2024.01.05 09:38:51
2024.01.05 10:38:43.783 !00 (GBPUSD,H1) USDCAD 2024.01.05 09:38:51
2024.01.05 10:38:43.783 !00 (GBPUSD,H1) EURGBP 2024.01.05 09:38:49
2024.01.05 10:38:43.783 !00 (GBPUSD,H1) GBPUSD 2024.01.05 09:38:49
2024.01.05 10:38:43.783 !00 (GBPUSD,H1) POZ3 1970.01.01 00:00:00
2024.01.05 10:38:43.783 !00 (GBPUSD,H1) EDH4 1970.01.01 00:00:00
2024.01.05 10:38:43.783 !00 (GBPUSD,H1) BRZ3 1970.01.01 00:00:00
 
It is possible to get additional data by switching between servers. I don't know if this is possible to implement through code.
 
Nauris Zukas #:
It is possible to get additional data by switching between servers. I don't know if it is possible to implement it through the code.

If by "between servers" you mean "between brokers", then hardly, unless you try to play with profiles.

But if I really needed to switch between different servers of one broker (Open had many, Finam had two), I would do it via iptables/nftables and my bash scripts. But it's easier for me here, I have Linux.

 
JRandomTrader #:

If by "between servers" you mean "between brokers".


.

 
Nauris Zukas #:


Yes, in principle, it is possible.

But, since there is no way to find out the name and ip of the server from the MQL-program, you will have to find them out manually by switching servers and checking which ip the connection is going to.

Then it is possible, making changes in the configuration of the firewall, to prohibit the connection to some server (here it is necessary to rejack packets, not drop them to avoid timeout), forcing MT to switch to another one.

Again, it's not hard for me to do this under Linux, but I can't imagine how to do it in Windows.

 
Alexey Viktorov #:

Try checking the time of the last quote.

if 0, there is no data.

I just checked against the open charts.

This also applies to a similar case:

I tried this option. Unfortunately, it does not fit. If a symbol is added to the [Market Watch] window for the first time, there is no data on it yet and SymbolInfoTick returns null values.

If ticks come rarely, all such symbols will be excluded.

fxsaber #:

It is easy to get working symbols by hand.

  1. Add all symbols to the Market Watch in a couple of clicks.
  2. In a couple of seconds ticks on them will be received.
  3. Sorting with one mouse click by time.
  4. Deleting one of the tails of the obtained list using the Del key.
All this will take up to half a minute.

No. You need a full automatic.

Vladimir Pastushak #:

I've been fighting with it for 6 years already, and I ask developers to put order here.

Unfortunately, this problem is not solved, and at the moment there are situations when the terminal hangs up when anyone accesses a financial instrument for the first time.

I noticed it only when calling the following functions:

  • Bars()
  • iBars()
  • SeriesInfoInteger(symbol, PERIOD_M1, SERIES_BARS_COUNT)

//---

Terminal developers:

1. exclude the possibility of adding symbols without data on the trade server.

2. Make it possible to disable symbol deletion blocking from the [Market Watch] window or fix it if it is a bug. Now it can be done only by restarting the terminal.

3. For functions like CopyXXX , add an additional optional parameter to set timeout (maximum time to wait for data from the server).

I can't reproduce this right now. So far it works without delay. But it seems that in some cases it can happen.

4. fix the bug with infinite waiting when using Bars(), iBars(), SeriesInfoInteger(symbol, PERIOD_M1, SERIES_BARS_COUNT) functions in cases when:

  • no connection to the server
  • no data on the symbol

An attempt to delete the programme from the chart may cause the terminal to hang for several minutes.

5. Fix the bug with infinite waiting when using functions if there is no connection to the server:

  • SeriesInfoInteger(symbol, PERIOD_M1, SERIES_FIRSTDATE)
  • SeriesInfoInteger(symbol, PERIOD_M1, SERIES_LASTBAR_DATE)
  • SeriesInfoInteger(symbol, PERIOD_M1, SERIES_SERVER_FIRSTDATE)

In this case you can also add an additional optional parameter to set the timeout (maximum time to wait for data from the server).

//---

P.S. So far I have settled on the variant with checking for data with functions like CopyXXX. But I will watch whether the problem described above will appear again.

 

The most productive and shortest way to determine the day of the week by time:

uchar WhatWeekDay(datetime t) {
   return uchar(t/(24*60*60)+3 )%7+1;
}

returns a value between 1 and 7

1 - Monday

...

7 - Sunday