Questions from Beginners MQL5 MT5 MetaTrader 5 - page 1159

 
Vladimir Karputov:
Are you sure that the exchange works for the requested symbol at night?

I don't force the terminal to send me ticks at a specific time which it doesn't have, I just send a request:

from=0,// the date from which the ticks are requested.

count=0// number of ticks to be received

And it sends me the history itself, doesn't it?

 
VANDER:

I don't force the terminal to send me ticks at a specific time which it doesn't have, I just send a request:

from=0,// the date from which the ticks are requested.

count=0// number of ticks to be received

And it sends me the history itself, doesn't it?

If trades are closed for the requested symbol (e.g. it is nighttime) - where will the ticks for the requested symbol come from?
 

Checked, for the main symbol RTS-12.19 on which the Expert Advisor is running, the last tick was at 23:59:30 and SBRF-12.19 at 23:52:21 so it could not download the ticks?

And how interesting is the SymbolInfoTick function helping it to become smart?

 
VANDER:

Checked, for the main symbol RTS-12.19 on which the Expert Advisor is running, the last tick was at 23:59:30 and SBRF-12.19 at 23:52:21 so it could not download the ticks?

And how interesting is the SymbolInfoTick function that helps him understand it?

Forum on Trading, Automated Trading Systems and Strategy Tests

FAQ from Beginners MQL5 MT5 MetaTrader 5

Vladimir Karputov, 2019.12.08 13:20

If bidding on the requested symbol is closed (e.g. it is nighttime) - where will the requested symbol get its ticks from?

 
VANDER:

Checked, for the main symbol RTS-12.19 on which the Expert Advisor is running, the last tick was at 23:59:30 and SBRF-12.19 at 23:52:21 so it could not download the ticks?

And how is the SymbolInfoTick function interesting?

Here's the EA:

//+------------------------------------------------------------------+
//|                                                  CopyTicks_1.mq5 |
//|                              Copyright © 2015, Vladimir Karputov |
//|                                           http://wmua.ru/slesar/ |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2015, Vladimir Karputov"
#property link      "http://wmua.ru/slesar/"
#property version   "1.100"
#property description "Сравнение трёх режимов получения тиков"
//--- input parameters
input string   name  = "RTSSiZ9";      // символ по которому запрашиваем тики
input int      ticks = 3000;           // количество запрашиваемых тиков
//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit()
  {
  SymbolSelect(name,true);
//--- succeed
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick()
  {
//--- массив для приема тиков
   MqlTick ExTicks[];
//--- запросим тики
   ResetLastError();
   int copied=CopyTicks(name,ExTicks,COPY_TICKS_ALL,0,ticks);
//--- если тики получены, то выведем на график значения Bid и Ask
   Print("Получено тиков: ",copied," код ошибки: ",GetLastError());
   if(copied>1)
     {
      Print("Тик: ",ExTicks[0].time," bid: ",ExTicks[0].bid," ask: ",ExTicks[0].ask," last: ",ExTicks[0].last," [0]");
      Print("Тик: ",ExTicks[copied-1].time," bid: ",ExTicks[copied-1].bid," ask: ",ExTicks[copied-1].ask," last: ",ExTicks[copied-1].last," [",copied-1,"]");
     }
  }
//+------------------------------------------------------------------+

Running on RTSSRZ9 (this is SBRF-Dec19) - here are the settings:


Requesting ticks in RTSSiZ9 (this is Si-Dec19).

Result:

2019.08.30 07:00:00   Получено тиков: -1 код ошибки: 4004
2019.08.30 07:00:01   Получено тиков: 2 код ошибки: 0
2019.08.30 07:00:01   Тик: 2019.08.30 07:00:00 bid: 22552.0 ask: 22697.0 last: 0.0 [0]
2019.08.30 07:00:01   Тик: 2019.08.30 07:00:01 bid: 22552.0 ask: 22697.0 last: 0.0 [1]
2019.08.30 07:00:02   Получено тиков: 3 код ошибки: 0
2019.08.30 07:00:02   Тик: 2019.08.30 07:00:00 bid: 22552.0 ask: 22697.0 last: 0.0 [0]
2019.08.30 07:00:02   Тик: 2019.08.30 07:00:02 bid: 22425.0 ask: 22856.0 last: 0.0 [2]
2019.08.30 07:00:02   Получено тиков: 4 код ошибки: 0
2019.08.30 07:00:02   Тик: 2019.08.30 07:00:00 bid: 22552.0 ask: 22697.0 last: 0.0 [0]

and so on ...


That is, on real server everything works. If it doesn't work for you: 1. Work on a real server, not a demo server, 2. Check your code.

Files:
 

The account is more than real, I trade on it. I used your code, even set all the settings exactly and you will laugh, here is the full log:


2019.12.08 21:08:38.787 MetaTester 5 started on 127.0.0.1:3000
2019.12.08 21:08:38.790 initialization finished
2019.12.08 21:08:39.088 login (build 2265)
2019.12.08 21:08:39.120 4372 bytes of account info loaded
2019.12.08 21:08:39.120 1482 bytes of tester parameters loaded
2019.12.08 21:08:39.120 1212 bytes of input parameters loaded
2019.12.08 21:08:39.138 29043 bytes of symbols list loaded
2019.12.08 21:08:39.138 expert file added: Experts\CopyTicks_1.ex5. 16437 bytes loaded
2019.12.08 21:08:39.152 6116 Mb available, 76 blocks set for ticks generating
2019.12.08 21:08:39.152 initial deposit 10000.00 USD, leverage 1:100
2019.12.08 21:08:39.153 successfully initialized
2019.12.08 21:08:39.153 37 Kb of total initialization data received
2019.12.08 21:08:39.153 Intel Core i5-3450  @ 3.10 GHz, 8157 MB
2019.12.08 21:08:39.198 RTS-12.19: symbol to be synchronized
2019.12.08 21:08:39.199 RTS-12.19: symbol synchronized, 4120 bytes of symbol info received
2019.12.08 21:08:39.199 RTS-12.19: history synchronization started
2019.12.08 21:08:39.201 RTS-12.19: load 33 bytes of history data to synchronize in 0:00:00.000
2019.12.08 21:08:39.201 RTS-12.19: history synchronized from 2018.01.12 to 2019.12.06
2019.12.08 21:08:39.201 RTS-12.19: ticks synchronization started
2019.12.08 21:08:39.202 RTS-12.19: load 40 bytes of tick data to synchronize in 0:00:00.000
2019.12.08 21:08:39.202 RTS-12.19: history ticks synchronized from 2019.01.03 to 2019.12.05
2019.12.08 21:08:39.205 RTS-12.19,H1: history cache allocated for 2480 bars and contains 971 bars from 2018.01.12 13:00 to 2019.08.29 23:00
2019.12.08 21:08:39.205 RTS-12.19,H1: history begins from 2018.01.12 13:00
2019.12.08 21:08:39.207 RTS-12.19,H1 (Open-Broker): generating based on real ticks
2019.12.08 21:08:39.207 RTS-12.19,H1: testing of Experts\CopyTicks_1.ex5 from 2019.08.30 00:00 to 2019.11.26 00:00 started with inputs:
2019.12.08 21:08:39.207   name=SBRF-12.19
2019.12.08 21:08:39.207   ticks=3000
2019.12.08 21:08:39.263 SBRF-12.19: symbol to be synchronized
2019.12.08 21:08:39.263 SBRF-12.19: symbol synchronized, 4120 bytes of symbol info received
2019.12.08 21:08:40.615 RTS-12.19 : real ticks begin from 2019.01.03 00:00:00
2019.12.08 21:08:55.958 2019.08.30 00:03:46   Получено тиков: -1 код ошибки: 4401
2019.12.08 21:08:56.877 2019.08.30 00:03:46   Получено тиков: -1 код ошибки: 4401
2019.12.08 21:08:57.764 2019.08.30 09:52:14   Получено тиков: -1 код ошибки: 4401
2019.12.08 21:08:58.739 2019.08.30 10:00:01   Получено тиков: -1 код ошибки: 4401
2019.12.08 21:08:59.784 2019.08.30 10:00:01   Получено тиков: -1 код ошибки: 4401
2019.12.08 21:09:04.628 2019.08.30 10:00:03   Получено тиков: -1 код ошибки: 4401
2019.12.08 21:09:05.579 2019.08.30 10:00:04   Получено тиков: -1 код ошибки: 4401
2019.12.08 21:09:06.596 2019.08.30 10:00:06   Получено тиков: -1 код ошибки: 4401

The only difference is it starts at night, but then it's the same even in the morning.

 
VANDER:

The account is more than real, I trade on it. I used your code, even set all the settings exactly and you will laugh, here is the full log:


The only difference is it starts at night, but then it's the same even in the morning...

ERR_HISTORY_NOT_FOUND

4401

Requested history not found

From what date and until what date isSBRF-12.19 traded? Are these dates between 2019.08.30 and 2019.11.26?

 
Vladimir Karputov:

ERR_HISTORY_NOT_FOUND

4401

Requested history not found

Since when isSBRF-12.19 traded and until when? Do these dates fall within the range 2019.08.30-2019.11.26?

Yes they do, it happens on all dates


Forget it, I've found a solution for me, I use the function

SymbolInfoTick(необходимый символ)

Then CopyTicks() starts working with it, maybe Openbox glitches on other brokers I haven't checked, maybe it will be useful for someone.

 
VANDER:

Yes, they do, it happens on all dates.


Ok forget it, I've found a way out for me, use function before

Then CopyTicks() starts working with it, maybe it glitches on other brokers I haven't checked, maybe it will be useful for someone.

It clearly depends on the trading server - it worked for me.
Maybe they don't update their server part for ten years.
 
fxsaber :

What prevents to fix the code so that there are no warnings?

When you have 600 warnings, you have to find lines with errors (I actually have more if I enable strict mode)

And almost all warnings are useless. Because many of them are about hidden variables or type conversions. Maybe some people think you can get it wrong, but that's not common among experienced programmers.

Mt4 was justified for beginners. But the current mql5 language is sophisticated enough to have a purpose for beginners. And experienced programmers don't need 600 lines about something clearly done for a reason


Obviously this is my subjective opinion, but other languages let you decide how much verbose level you want